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