#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    map<string, int> sum;
    sum["A"] = 0;
    sum["B"] = 0;
    sum["AB"] = 0;
    sum["O"] = 0;
    int n;
    char c;
    string type;
    while (cin >> n >> c >> type)
    {
        sum[type]++;
    }

    OP(sum["A"]);
    OP(sum["B"]);
    OP(sum["AB"]);
    OP(sum["O"]);
    return 0;
}
