#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

int main(){
  int a,ti[3],x=0,A=0,B=0,O=0,z=0;
  char b;
  while(scanf("%d,%s",&a,ti) != EOF){
    if(ti[0] == 'B'){
      B++;
    }
    else if(ti[0] == 'O'){
      O++;
    }
    else if(ti[1] == 'B'){
      z++;
    }
    else if(ti[0] == 'A'){
      A++;
    }
  }
  cout << A << endl << B << endl << z << endl << O << endl;
}