import Data.Maybe
import Data.Array
import qualified Data.ByteString.Char8 as C

parseInt :: C.ByteString -> Int
parseInt = fst . fromJust . C.readInt

main :: IO ()
main = do
  n <- parseInt <$> C.getLine
  line <- C.getLine
  let s = C.unpack line
      a = array (1, n) $ zip [1..] s
      count m = length $ filter (\i -> a!(m-i) /= a!m && a!m /= a!(m+i) && a!(m-i) /= a!(m+i)) [1..min (m-1) (n-m)]
      f c = length $ filter (==c) s
      ans = (f 'R') * (f 'G') * (f 'B') - sum (map count [1..n])
  putStrLn $ show ans
