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

int main()
{
	int a = 0, b = 0, o = 0, ab = 0, k;
	string s;
	while (true) {
		cin >> s;
		if (s.size() == 0)break;
		if (s[2] == 'A' && s[3] != 'B')a++;
		else if (s[2] == 'B')b++;
		else if (s[2] == 'A')ab++;
		else o++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}