#include<iostream>

using namespace std;

int main() {
	
	int Blood_sum[4] = {};
	int n;
	char ch;
	string Blood;
	
	while(cin >> n >> ch >> Blood)	{
		
		if(Blood == "A")
			Blood_sum[0]++;
		
		if(Blood == "B")
			Blood_sum[1]++;
			
		if(Blood == "AB")
			Blood_sum[2]++;
			
		if(Blood == "O")
			Blood_sum[3]++;
		
	}
	
	for(int i=0;i<4;i++)
		cout << Blood_sum[i] << "\n";
		
	return 0;
}

