a = b = o = ab = 0
while query = gets
  break if query == "\n"
  no, type = query.chomp.split(",")
  
  case type
  when "A" then a += 1
  when "B" then b += 1
  when "O" then o += 1
  when "AB" then ab += 1
  end
end
puts a,b,ab,o