f=lambda x:e.count(x)+e.count(x+'2')*2 while 1:e=input().split();print(*[c+str(f(c))*(f(c)>1)for c in'm kg s A K mol cd'.split()if f(c)])