#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    map<string, int> m;
    m["A"] = 0;
    m["B"] = 0;
    m["AB"] = 0;
    m["O"] = 0;
    int a; char c; string s;
    while (cin >> a >> c >> s){
        m[s]++;
    }
    cout << m["A"] << "\n" << m["B"] << "\n" << m["AB"] << "\n" << m["O"] << endl;
}