#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int x, a, b, ab, o;
    string s;
    a = b = ab = o = 0;
    while (true) {
        cin >> x;
        cin.ignore();
        cin >> s;
        if (cin.eof()) break;
        else if (s == "A") a++;
        else if (s == "B") b++;
        else if (s == "AB") ab++;
        else if (s == "O") o++;
    }
    cout << a << endl;
    cout << b << endl;
    cout << ab << endl;
    cout << o << endl;
    return 0;
}