import sys

fin = open(sys.argv[1], "r")

line = fin.readline()

author = {}

while line:
    if line.split()[0] == "AUT":
        cauthor = " ".join(line.split()[1:])
	if cauthor in author:
	    author[cauthor] += 1
        else:
	    author[cauthor] = 1
    line = fin.readline()

fin.close()

tauthor = [(author[cauthor], cauthor) for cauthor in author]
tauthor.sort()
tauthor.reverse()

for x in tauthor:
    print x

