#include<iostream>
#include<string>
using namespace std;
int main()
{
	int s[50];
	string str[50];
	int i = 0;
	int a, b, ab, o = 0;
	while (scanf_s("%d,%s", s[i], str[i])) {
		i++;
		if (str[i] == "A") {
			a++;
		}
		else if (str[i] == "B") {
			b++;
		}
		else if (str[i] == "AB") {
			ab++;
		}
		else if (str[i] == "O") {
			o++;
		}
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;


	return 0;
}