#include<iostream>
#include<string>
using namespace std;

int main()
{
    int num;
    int blood[4] = {};

    char p;
    string b;

    while( cin >> num >> p >> b )
    {
        if( b == "A" )
            blood[0]++;
        if( b == "B" )
            blood[1]++;
        if( b == "AB" )
            blood[2]++;
        if( b == "O" )
            blood[3]++;
    }
    for( int i = 0; i < 4; i++ )
    cout << blood[i] << endl;
    return 0;
}
