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

int main(){
	int a=0, b=0, o=0, ab=0;
	int tmp;
	char blood[3];
	while(scanf("%d,%s", &tmp, blood) != EOF){

		if(blood[1]=='B') ab++;
		else if(blood[0]=='A')a++;
		else if(blood[0]=='B')b++;
		else o++;
	}

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