import Control.Monad.State
import Data.List.Split
data BH = Hist { a :: Int,
                 b :: Int,
                 ab :: Int,
                 o :: Int}

main = do
    groups <- fmap (map (last.splitOn ",").lines) getContents
    let hist = execState ( foldl1 (>>) $ fmap add groups) (Hist 0 0 0 0)
    print $ a hist
    print $ b hist
    print $ ab hist
    print $ o hist

add :: String -> State BH ()
add g 
  | g == "A" = get >>= \bh -> put $ bh { a = a bh + 1}
  | g == "B" = get >>= \bh -> put $ bh { b = b bh + 1}
  | g == "AB" = get >>= \bh -> put $ bh { ab = ab bh + 1}
  | g == "O" = get >>= \bh -> put $ bh { o = o bh + 1}