d = {"A": 0, "AB": 0, "B": 0, "O": 0}

flag = 1

while flag:

    try:

        _, blood_type = input().split(',')

        d[blood_type] += 1

    except:

        for blood_type in ["A", "B", "AB", "O"]:

            print((d[blood_type]))

        flag = 0
d = []

flag = 1

while flag:

    try:

        _, blood_type = input().split(',')

        d.append(blood_type)

    except:

        for blood_type in ["A", "B", "AB", "O"]:

            print((d.count(blood_type)))

        flag = 0
d = {"A": 0, "AB": 0, "B": 0, "O": 0}
flag = 1
while flag:
    try:
        _, blood_type = input().split(",")
        d[blood_type] += 1
    except:
        for blood_type in ["A", "B", "AB", "O"]:
            print((d[blood_type]))
        flag = 0

d = []
flag = 1
while flag:
    try:
        _, blood_type = input().split(",")
        d.append(blood_type)
    except:
        for blood_type in ["A", "B", "AB", "O"]:
            print((d.count(blood_type)))
        flag = 0

-d = {"A": 0, "AB": 0, "B": 0, "O": 0} +d = [] -        d[blood_type] += 1 +        d.append(blood_type) -            print((d[blood_type])) +            print((d.count(blood_type)))