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

using namespace std;

int main() {

	int a;
	char d;
	int counter[4] = {0};
	string b;

	while (cin >> a >> d >> b) {

		if (b == "A\0") {
			counter[0]++;
		} else if (b == "B\0") {
			counter[1]++;
		} else if (b == "AB\0") {
			counter[2]++;
		} else {
			counter[3]++;
		}
	}

	for (int i = 0; i < 4; i++) {
		cout << counter[i] << endl;
	}

	return 0;
}