
import std.stdio;
import std.string;
import std.conv;

void main() {
  uint[string] table;
  while(true) {
    string line = readln.chomp;
    if (stdin.eof) break;
    auto data = line.split(",");
    table[data[1]] += 1;
  }
  foreach(type; ["A", "B", "AB", "O"]) {
    writeln(table[type]);
  }
}