a =[]
b = []
o = []
ab = []
xx =gets
until xx.nil?
 x = xx.chomp
 y = x.split(",")

 if y[1] == "A"
  a << y[0]
 elsif y[1] == "B"
  b << y[0]
 elsif y[1] == "O"
  o << y[0]
 elsif y[1] == "AB"
  ab << y[0]
 end
 xx = gets
end
puts a.length
puts b.length
puts ab.length
puts o.length
