#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int get(string s)
{
	if (s == "A")
	{
		return 0;
	}
	else if (s == "B")
	{
		return 1;
	}
	else if (s == "AB")
	{
		return 2;
	}
	else
	{
		return 3;
	}
}

int main()
{
	vector<int> a(4);

	string s;
	for (; cin >> s;)
	{
		stringstream ss;
		ss << s;

		int no;
		ss >> no;

		ss.ignore();

		string x;
		ss >> x;
		a.at(get(x))++;;

	}

	for (int i = 0; i < 4; i++)
	{
		cout << a.at(i) << endl;
	}
}
