#include <iostream>
#include <string>

using namespace std;

int main() 
{
	int n, a = 0, b = 0, ab = 0, o = 0;
	string bld;

	while(cin >> n >> bld){
		if(bld[2] == 'B')    ab++;
		else if(bld[1] == 'A')    a++;
		else if(bld[1] == 'B')    b++;
		else if(bld[1] == 'O')    o++;
	}

	cout << a << endl << b << endl << ab << endl << o << endl;
	
	return 0;
}