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

struct BloodData {
    int number;
    string bloodGroup;
}



void main() {
    string[] input = new string[](2);
    BloodData[] list;
    int[] count = [0, 0, 0, 0];

    while ((input = readln.chomp.split(",")).length != 0) {
        BloodData temp = {number:input[0].to!int, bloodGroup:input[1]};
        list ~= temp;
    }

    foreach (data; list) {
        if (data.bloodGroup == "A") {
            count[0]++;
        } else if (data.bloodGroup == "B") {
            count[1]++;
        } else if (data.bloodGroup == "AB") {
            count[2]++;
        } else if (data.bloodGroup == "O") {
            count[3]++;
        }
    }

    foreach (num; count) {
        writeln(num);
    }
}