#include <cstdio>
#include <string>
using namespace std;

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