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

int main(){
  int num,a,b,o,ab;
  char c1;
  string c2;

  while(cin>>num>>c1>>c2){
      if(c2=="A") 
	a++;
      else if(c2=="B") 
	b++;
      else if(c2=="AB") 
	ab++;
      else o++;
  }

  cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;

 return 0;
}