#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str;
    int countA,countB,countO,countAB;
    countA=0;
    countB=0;
    countO=0;
    countAB=0;
    while (cin>>str) {
        char s = str.at(str.size()-1);
        if (s=='B' && str.at(str.size()-2)=='A') {
            countAB++;
        } else if (s=='A') {
            countA++;
        } else if (s=='B') {
            countB++;
        } else if (s=='O') {
            countO++;
        }
    }
    cout<<countA<<endl;
    cout<<countB<<endl;
    cout<<countAB<<endl;
    cout<<countO<<endl;
}

