require 'scanf'
sum = {}
sum["A"] = 0
sum["B"] = 0
sum["AB"] = 0
sum["O"] = 0
while line = gets
  n,t = line.split(',').map(&:to_s)
  sum[t.chomp] += 1
end
puts sum["A"]
puts sum["B"]
puts sum["AB"]
puts sum["O"]