#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,A=0,B=0,O=0,AB=0;
    char c;
    while(scanf("%d,%c",&a,&c) != EOF )
    {
        if(c=='A')A++;
        else if(c=='B')B++;
        else if(c=-'O')O++;
        else AB++;
    }
    cout<<A<<endl<<B<<endl<<O<<endl<<AB<<endl;
    return 0;
}