
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"]) {
    if (type in table)
      writeln(table[type]);
    else
      writeln(0);
  }
}