import Data.Char
import Data.List
main = interact $ unlines . map show . blood_groups . map (dropWhile (not.isUpper)) . lines
blood_groups bs = map (\b -> length $ filter (== b) bs) ["A","B","AB","O"]