#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a[4],x;
	char c[2];
	for(int i=0;i<4;i++)
		a[i]=0;
	while(scanf("%d,%s",&x,c),x){
		cout<<x<<' '<<c[0]<<endl;
		if(c[0]=='A'){
			if(c[1]=='B')
			a[2]++;
			else
			a[0]++;
		}
		else if(c[0]=='B')
		a[1]++;
		else if(c[0]=='O')
		a[3]++;
	}
	
	
	cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl<<a[3]<<endl;
	return 0;
}