import Data.List
main :: IO ()
main = do
  _ <- getLine
  s <- getLine
  let ss = zip [1,2..] s
  let rs = map fst $ filter (\(_, a) -> a == 'R') ss
  let gs = map fst $ filter (\(_, a) -> a == 'G') ss
  let bs = map fst $ filter (\(_, a) -> a == 'B') ss
  let ss = [(r, g, b) | r <- rs , g <- gs, b <- bs, r < g, g < b, (r-g) /= (g-b)]
  print $ length ss
  
