while 1:c=input().split().count;print(*[u+str(q)[:q-1]for u in'm kg s A K mol cd'.split()for q in[c(u)+2*c(u+'2')]if q])