#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	char s[3];
	int abo[4] = { 0 };
	while (scanf("%d,%s", &n, s)){
		if (s == "A"){
			abo[0]++;
		}
		else if (s == "B"){
			abo[1]++;
		}
		else if (s == "AB"){
			abo[2]++;
		}
		else{
			abo[3]++;
		}
	}
	for (int i = 0; i < 4; i++){
		cout << abo[i] << endl;
	}
}