#include <stdio.h>
#include <algorithm>

int main(void)
{
	char c[3];
	int n, i;
	int a[4];
	
	for (i = 0; i < 4; i++){
		a[i] = 0;
	}
	
	while (scanf("%d,%s", &n, c) != EOF){
		
		if (c[0] == 'A' && c[1] == 'B'){
			a[2]++;
		}
		
		else if (c[0] == 'A'){
			a[0]++;
		}
		else if (c[0] == 'B'){
			a[1]++;
		}
		if (c[0] == 'O'){
			a[3]++;
		}
		
	}
	
	for (i = 0; i < 4; i++){
		printf("%d\n", a[i]);
	}
	
	return (0);
}