#include<iostream>
#include<cstring>
using namespace std;

int main(){
  string c2,blood[4]={"A","B","O","AB"};
  int a,num[4]={};
  char c1;
  while(cin>>a>>c1>>c2)
    for(int i=0;i<4;i++)
      if(c2==blood[i]) num[i]++;

  for(int i=0;i<4;i++)
    cout<<num[i]<<endl;
  return 0;
}