#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int no; char delim; string blood;
    int A = 0, B = 0, AB = 0, O = 0;
    while (cin >> no >> delim >> blood) {
        if (blood == "A")  A++;  else
        if (blood == "B")  B++;  else
        if (blood == "AB") AB++; else
        if (blood == "O")  O++;
    }
    cout << A << endl << B << endl << AB << endl << O << endl;
    return 0;
}