#include <bits/stdc++.h>

using namespace std;

const string ord = "AB?O";

int main() {
    int no, ans[4] = {};
    char blood[3];
    while (scanf("%d,%s", &no, blood) != EOF) {
        if (strlen(blood) > 1) ans[2]++;
        else ans[ord.find(blood[0])]++;
    }

    for (int i = 0; i < 4; i++)
        cout << ans[i] << endl;

    return 0;
}
