#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n; string s;
  vector<int> a(4, 0);
  while( scanf("%d,%c", &n, s) != EOF ){
    if( s == "A" ) a[0]++;
    else if( s == "B" ) a[1]++;
    else if( s == "O" ) a[2]++;
    else if( s == "AB" ) a[3]++;
  }
  for(int i=0; i<4; i++) cout << a[i] << endl;

  return 0;
}

// EOF