import qualified Data.ByteString.Char8 as BS

--problem D
main = do
  n <- readLn :: IO Int
  str <- BS.getLine
  print.length $ filter (check str) [(x,y,z) | x <- [0..(n-1)], y <- [x+1..(n-1)], z <- [y+1..(n-1)]]

check str (x,y,z) = (BS.index str x) /= (BS.index str y)
                && (BS.index str y) /= (BS.index str z)
                && (BS.index str z) /= (BS.index str x)
                && y-x /= z-y