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

int main()
{  
  int x;
char y;
string z;
 int a=0,b=0,o=0,ab=0;

  while(cin >>x >>y >>z){
    if(z=="A") a++;
      else if(z=="B") b++;
      else if(z=="AB") ab++;
      else if(z=="O") o++;
  }
cout << a << endl;
cout << b << endl;
cout << ab << endl;
cout << o << endl;

return 0;
} 