#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int a,b,o,ab,jad2;
  char jad[2];
  a=0,b=0,o=0,ab=0;
  while(scanf("%d,%s",&jad2,jad)!=EOF){
    if(0==strcmp(jad,"A")){
      a++;
    }if(0==strcmp(jad,"B")){
      b++;
    }if(0==strcmp(jad,"O")){
      o++;
    }if(0==strcmp(jad,"AB")){
      ab++;
    }
  }
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<ab<<endl;
  cout<<o<<endl;
  return 0;
}