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

int main(){
	map<string, int> m;
	int num;
	char x;
	string blood;
	while(cin >> num >> x >> blood){
		m[blood]++;
	}

	cout << m["A"] << endl << m["B"] << endl << m["AB"] << endl << m["O"] << endl;
}