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

int main() {
  int a=0,b=0,ab=0,o=0,z;
  while(scanf("%d%*c",&z)==1) {
    string s;
    cin >> s;
    if(s=="A") a++;
    else if(s=="B") b++;
    else if(s=="O") o++;
    else ab++;
  }
  cout << a << endl << b << endl << ab << endl << o << endl;
  return 0;
}
