#include <iostream>
using namespace std;

int main(){
	int i, j, tmp, a[4]={0};
	char s1, s2, kanma,s3;
	
	
	while(1){
		cin>>s1>>kanma>>s2>>s3;
		if(cin.eof())break;

		if(s2=='A'){
			a[0]++;
		}
		else if(s2=='B'){
			a[1]++;
		}
		else if(s2=='O'){
			a[2]++;
		}else if(s2=='A'&&s3=='B'){
			a[3]++;
		}
		s3='zz';
	}
	int x=0;
	cout<<a[x++]<<endl;
	cout<<a[x++]<<endl;
	cout<<a[x++]<<endl;
	cout<<a[x++]<<endl;
	return 0;
}