#include <cstdio>
using namespace std;

int main() {
	int A=0,B=0,C=0,D=0;
	int num;
	char bl;
	while (scanf("%d, %c",num,bl)!=EOF) {
		switch(bl) {
			case 'A':
				A++;
				break;
			case 'B';
				B++;
				break;
			case 'AB':
				AB++;
				break;
			case 'O':
				O++;
				break;
		}
	}
	printf("%d\n%d\n%d\n%d\n",A,B,AB,O);
}