#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int x;
char t;
string s;

int a,b,o,ab;

int main(){
	a=b=o=ab=0;
	while(cin>>x>>t>>s){
		if(s=="AB") ab++;
		if(s=="A") a++;
		if(s=="B") b++;
		if(s=="O") o++;
	}
	cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
	return 0;
}