#include <iostream>
#include <string>
using namespace std;
int main(void){
    int num; //出席番号
    string s;
    char comma;
    int cnt_A = 0, cnt_B = 0, cnt_O = 0, cnt_AB = 0;
    while(cin >> num){
        cin >> comma >> s;
        if(s == "A") cnt_A++;
        if(s == "B") cnt_B++;
        if(s == "O") cnt_O++;
        if(s == "AB") cnt_AB++;
    }
    cout << cnt_A << endl;
    cout << cnt_B << endl;
    cout << cnt_AB << endl;
    cout << cnt_O << endl;
}

