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

int main(void)
{
	int ac = 0, bc = 0, oc = 0, abc = 0, num, n;
	string str;
	char ch;

	while (cin >> str)
	{
		n = str.size();
		if (n == 1)break;
		if (str[n - 2] == ',') {
			if (str[n - 1] == 'A')ac++;
			else if (str[n - 1] == 'B')bc++;
			else oc++;
		}
		else {
			abc++;
		}
	}
	cout << ac << endl;
	cout << bc << endl;
	cout << abc << endl;
	cout << oc << endl;
	return 0;
}
