import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import Data.List

main = abc162d

abc162d = do
    [n] <- getIntList
    s <- BS.getLine
    let rgbV = convRGB s (V.empty, V.empty, V.empty)
    print rgbV
    print $ solveD rgbV

convRGB s (r,g,b)
    | BS.null s = (r,g,b)
    | BS.head s == 'R' = convRGB (BS.tail s) (V.cons n r,g,b)
    | BS.head s == 'G' = convRGB (BS.tail s) (r,V.cons n g,b)
    | BS.head s == 'B' = convRGB (BS.tail s) (r,g,V.cons n b)
    where n = V.length r + V.length g + V.length b + 1

solveD (r,g,b)
    | V.length r == 1 = subSolveD (V.head r, g, b)
    | otherwise = subSolveD (V.head r, g, b) + solveD (V.tail r, g, b)

subSolveD (r,g,b)
    | V.length g == 1 = subSubSolveD (r, V.head g, b)
    | otherwise = subSubSolveD (r, V.head g, b) + subSolveD (r, V.tail g, b)

subSubSolveD :: (Int, Int, V.Vector Int) -> Int
subSubSolveD (r,g,b)
    | V.length b == 1 = result
    | otherwise = result + subSubSolveD (r, g, V.tail b)
    where sorted = sort [r,g,V.head b]
          result = if (sorted !! 1) - head sorted == (sorted !! 2) - (sorted !! 1)
                   then 0
                   else 1

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine