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

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