main = do
  n <- readLn :: IO Int
  str <- 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) = (str !! x) /= (str !!y) && (str !! y) /= (str !!z) && (str !! z) /= (str !!x)
  && y-x /= z-y