#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[4];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);
    int n;
    char buf[10];
    while (scanf("%d,%s", &n, buf) != EOF)
    {
        if (buf[0] == 'A' && buf[1] == 'B')
            arr[3]++;
        else if (buf[0] == 'A')
            arr[0]++;
        else if (buf[0] == 'B')
            arr[1]++;
        else if (buf[0] == 'O')
            arr[2]++;
    }

    cout << arr[0] << "\n"
         << arr[1] << "\n"
         << arr[3] << "\n"
         << arr[2] << endl;
    return 0;
}
