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

void main()
{
    int[string] memo;
    foreach(str; ["A", "B", "AB", "O"])
    {
        memo[str] = 0;
    }
    while(true)
    {
        auto line = readln;
        if(!line)break;
        auto f = line.chomp.split(",");
        ++memo[f[1]];
    }
    foreach(str; ["A", "B", "AB", "O"])
    {
        memo[str].writeln;
    }
}