#encoding:utf-8 No.0049 2014.10.3
data = []
while gets
  data.push $_.chomp.split(/,/)
end

a,b,ab,o = 0,0,0,0
data.length.times do |i|
  if data[i][1] == "A"
    a += 1
  elsif data[i][1] == "B"
    b += 1
  elsif data[i][1] == "AB"
    ab += 1
  else
    o += 1
  end
end

puts a
puts b
puts ab
puts o