#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n;
    char s[3];
    int a = 0, b = 0, ab = 0, o = 0;
    while(~scanf("%d,%s", &n, s)) {
        if(s[0] == 'A' && s[1] == 'B') {
            ab++;
        } else if(s[0] == 'A') {
            a++;
        } else if(s[0] == 'O') {
            o++;
        } else {
            b++;
        }
    }
    cout << a << '\n' << b << '\n' << ab << '\n' << o << endl;
}
