import Data.Char
isnLatin :: Char -> Bool
isnLatin c | ord c >= 65 && ord c <= 90  = False
		   | ord c >= 97 && ord c <= 122 = False
		   | otherwise					 = True

main = do
	str <- getContents
	print $ length $ filter (== "A") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "B") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "AB") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "O") $ (map snd.map (span(isnLatin)).lines) str