#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main(){
	int n, a, b ,o , ab;
	char delim;
	string type;
	
	while(cin >> n >> delim >> type){
		if(type == "A") a++;
		else if(type == "B") b++;
		else if(type == "AB") ab++;
		else if(type == "O") o++;
	}
	
	cout << a << '?\n' << b << '?\n' << ab << '?\n' << o << endl;
	
}