let n = int (stdin.ReadLine())
let s = stdin.ReadLine().ToCharArray()

// ri*gi*bi-(j-i=k-jなるもの)

let countby = 
    s |> Array.countBy id

let waste =
    let mutable cnt = 0
    for i in 0..n-1 do
        for j in i..n-1 do
            if
                j + j - i <= n - 1
                && s.[i] <> s.[j] 
                && s.[i] <> s .[j + j - i]
                && s.[j] <> s .[j + j - i]
                then
                    cnt <- cnt + 1
    cnt

countby
|> Array.fold (fun acc x -> acc * snd x ) 1
|> fun x -> x - waste
|> string
|> stdout.WriteLine