#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int num, ans[4] = {0}, i;
	char str[3], s[4][3] = {"A","B","AB","O"};
	while(scanf("%d%*c%s",&num,str) != EOF){
		for(i = 0;i < 4;i++){
			if(!strcmp(s[i],str)){
				ans[i]++;
			}
		}
	}
	for(i = 0;i < 4;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}