#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int n,A=0,B=0,AB=0,O=0;
	char bt[3];
	
	while(scanf("%d,%s",&n,bt)+1){
		if(bt[0]=='A'){
			if(bt[1]=='B')
				++AB;
			else ++A;
		}else if(bt[0]=='B'){
			++B;
		}else if(bt[0]=='O'){
			++O;
		}
	}
	cout<<A<<endl<<B<<endl<<AB<<endl<<O<<endl;
	return 0;
}