#include <stdio.h>

int main(void){
    int a=0,b=0,ab=0,o=0,d;
    char c[3];
    while(scanf("%d,%s",&d,c)!=EOF){
        if(c[0]=='A'){
            a++;
        }
        else if(c[0]=='B'){
            b++;
        }
        else if(c[0]=='O'){
            o++;
        }
        else{
            ab++;
        }
        
    }
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    return 0;
}