

ans str = length [() | i <- [1..(length str) - 2]
					 , j <- [i+1..(length str) - 1]
					 , k <- [j+1..length str]
					 , str !! (i - 1) /= str !! (j - 1)
					 , str !! (i - 1) /= str !! (k - 1)
					 , str !! (j - 1) /= str !! (k - 1)
					 , j - i /= k - j]

main = do
	_ <- getLine
	str <- getLine
	putStrLn $ show . ans $ str

