#include<iostream>
#include<string>
using namespace std;
int main(void){    
int w;    
char e;    
string r;   
 int a,b,c,d=0;    
while(cin>>w>>e>>r){         
if(r=="A")a++;        
 if(r=="B")b++;         
if(r=="AB")c++;        
 if(r=="O")d++;   
 }    
cout<<a<<b<<c<<d<<endl;   
 return 0;}