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

using namespace std;

int main() {

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

	while (cin >> a >> d >> b) {
		cin >> c;
		if (b == 'A') {
			if (c == 'B') {
				counter[2]++;
			} else {
				counter[0]++;
			}
		} else if (b == 'B') {
			counter[1]++;
		} else {
			counter[3]++;
		}

	}

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

	return 0;
}