main = do
    n <- read <$> getLine
    s <- getLine
    print $ length [(i, j, k) | i <- [1..(n-2)], j <- [(i+1)..(n-1)], k <- [(j+1)..n],
                    s !! (i-1) /= s !! (j-1), s !! (i-1) /= s !! (k-1), s !! (j-1) /= s !! (k-1), j-i /= k-j]
