import           Data.List

solve :: [String] -> (Int, Int, Int, Int)
solve = foldl f (0, 0, 0, 0)
  where f (a, b, ab, o) s
          | "AB" `isSuffixOf` s = (a, b, ab + 1, o)
          | "B"  `isSuffixOf` s = (a, b + 1, ab, o)
          | "A"  `isSuffixOf` s = (a + 1, b, ab, o)
          | "O"  `isSuffixOf` s = (a, b, ab, o + 1)
          | otherwise           = (a, b, ab, o)

main :: IO ()
main = getContents >>= printResult . solve . lines
  where printResult (a, b, ab, o) = do
          print a
          print b
          print ab
          print o