#include<iostream>
#include<stdio.h>
#include<string>
#include<map>
using namespace std;

int main() {
	string ketsueki;
	map<string,int> num;
	int hoge;
	
	num["A"] = 0;
	num["B"] = 0;
	num["O"] = 0;
	num["AB"] = 0;
	
	
	while ( ~scanf("%d,",&hoge)){
		cin >> ketsueki;
		num[ketsueki]++;
	}
	
	cout << num["A"] << endl << num["B"] << endl << num["AB"] << endl << num["O"] << endl;
	
	return 0;
}