import std.stdio, std.string, std.algorithm, std.conv, std.range, std.math;

void main() {
  int[string] counter;

  foreach (string line; lines(stdin)) {
    auto blood = line.chomp.split(",")[1];
    counter[blood]++;
  }

  foreach (k; ["A", "B", "AB", "O"]) {
    counter[k].writeln;
  }
}