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

int main()
{
	int a = 0, b = 0, o = 0, ab = 0, k;
	char C;
	while (scanf("%d,%c", &k, &C) != EOF) {
		if (C == 'A')a++;
		else if (C == 'B')b++;
		else if (C == 'O')o++;
		else ab++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}