import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  xs <- inpi $ btoi . (!!1) . splitOn ","
  mapM_ print $ solve xs

solve :: [Int] -> [Int]
solve  = map length . group . sort

btoi :: String -> Int    
btoi c | c == "A" = 0
       | c == "B" = 1
       | c == "AB" = 2
       | otherwise = 3

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents