#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	char x, c;
	string s;
	int cnt_a=0,cnt_b=0,cnt_o=0,cnt_ab=0;
	while(cin >> n >> x >> s){
		if(s=="A"){
			cnt_a++;
		}
		else if(s=="B"){
			cnt_b++;
		}
		else if(s=="O"){
			cnt_o++;
		}
		else if("AB"){
			cnt_ab++;
		}
	}
	cout<<cnt_a << endl << cnt_b << endl << cnt_ab << endl << cnt_o << endl;
}