#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
	int hito[100] = {0};
	int a = 0,b = 0,ab = 0,o = 0;
	string s;

	for(int i = 0; i < 100; i++){

		scanf("%d,",&hito[i]);
		cin >> s;

		if(hito[i] == 0 && s == "0") break;

		if(s == "A"){
			a++;
		}else if(s == "B"){
			b++;
		}else if(s == "AB"){
			ab++;
		}else if(s == "O"){
			o++;
		}
	}

	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;

	return 0;
}