main = getLine >> getLine >>= print . triples

triples :: String -> Int
triples xs = let xs' = zip [1..] xs in 
               length [(r,g,b) | 
                       (i,r) <- xs', 
                       (j,g) <- xs', 
                       (k,b) <- xs', 
                       i < j && j < k && 
                       r /= g && r /= b && g /= b 
                       && j-i /= k-j]