#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int a[4];

int main(){
	for(int i = 0; i < 4; i++) a[i] = 0;
	string str;
	while(cin >> str){
		if(str[str.size()-1] == 'A') a[0]++;
		else if(str[str.size()-1] == 'O') a[3]++;
		else if(str[str.size()-1] == 'B' && str[str.size()-2] == 'A') a[2]++;
		else a[1]++;
	}
	for(int i = 0; i < 4; i++){
		cout << a[i] << endl;
	}
}