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

int main()
{
	int n, b[4] = {};
	string str;
	char d;

	while (cin >> n >> d >> str){
		if(str == "A")	b[0]++;
		if(str == "B")	b[1]++;
		if(str == "AB")	b[2]++;
		if(str == "O")	b[3]++;

	}
	
	for (int i = 0; i < 4; ++i)
		cout << b[i] << endl;

	return 0;
}