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

int main() {
	int A=0,B=0,C=0,D=0;
	int num;
	string bl;
	while (cin >> num >> bl) {
		if (bl=="A") {
				A++;
		} else if (bl=="B") {
				B++;
		} else if (bl=="AB") {
				C++;
		} else if (bl=="O") {
				D++;
		}
	}
	printf("%d\n%d\n%d\n%d\n",A,B,C,D);
}