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

int main(){
  string c2,blood[4]={"A","B","O","AB"};
  int num,a[4]={};
  char c1;

  for(int i=0;i<4;i++)
    cout<<a[i]<<endl;

  while(cin>>num>>c1>>c2){
    for(int i=0;i<4;i++)
      if(c2==blood[i]) 
	a[i]++;
  }
  for(int i=0;i<4;i++)
    cout<<a[i]<<endl;
  return 0;
}