925 B | 925 chars
import sys
from math import sqrt, pi, sin, factorial, ceil, floor
from datetime import datetime, timedelta
# sys.setrecursionlimit(10**7)
BLANK = " "
# inp = input
inp = lambda : sys.stdin.readline().rstrip()
mii = lambda x = BLANK : [*map(int,inp().split(x))]
mfi = lambda x = BLANK : [*map(float,inp().split(x))]
ii = lambda : int(inp())
fi = lambda : float(inp())
p = print
def solve():
while 1:
n = ii()
if n == 0:
break
# M or L => Joe
# S => James
# 12 same, up => Jean
# down => jane
cnt = [0] * 5
for _ in range(n):
s = input()
if s == "X":
cnt[-1] += 1
elif s in "ML":
cnt[0] += 1
elif s == "S":
cnt[3] += 1
elif int(s) >= 12:
cnt[1] += 1
else:
cnt[2] += 1
p(*cnt)
if __name__ == "__main__":
tc = 1
for t in range(1, tc+1):
ret = solve()