#!/usr/bin/ruby                                                                                                                                   
# -*- coding: utf-8 -*-                                                                                                                           

a = 0; b = 0; o = 0; ab = 0;
while s = gets
  btype = (s.chomp.split(','))[1]
  if btype == "A"
    a += 1
  elsif btype == "B"
    b += 1
  elsif btype == "O"
    o += 1
  else
    ab += 1
  end
end
puts a
puts b
puts ab
puts o