#!/usr/bin/python

from collections import OrderedDict
my_dic=OrderedDict()
no_of_words=input()
words=[]
for i in range(0,no_of_words):
	words.append(raw_input())
my_dic={n:0 for n in words}
print my_dic
print len(list(set(words)))

for i in range(0,no_of_words):
	my_dic[words[i]]=words.count(words[i])
	print my_dic
output=""
for i in reversed(my_dic.values()):
	output+=str(i)+" "
print output
		
