#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include<vector>
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){
//	cout << n << x << s << endl;
//	transform(s.begin(),s.end(),s.begin(),toupper)
	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;

}