#include <iostream>
#include<string>
using namespace std;
string s;
int a=0,b=0,o=0,ab=0;
int main() {
	while(cin>>s){
	if(*(s.end()-1)=='A'){	
	a++;}else
	if(*(s.end()-2)=='A'){	
	ab++;}else
	if(*(s.end()-1)=='O'){	
	o++;}else b++;
	}
	cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
	return 0;
}
