#include<stdio.h>
#include<string.h>

int main(void)
{
	int a,b,o,ab,i;
	char s[5];
	a=b=o=ab=0;
	while(scanf("%d,%s",&i,&s)!=EOF){

		if(strcmp(s,"A")==0)
			a++;
		else if(strcmp(s,"B")==0)
			b++;
		else if(strcmp(s,"O")==0)
			o++;
		else if(strcmp(s,"AB")==0)
			ab++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}