l=[] try: while 1:l+=[raw_input()] except:l.sort(cmp=lambda x,y:len(x)==len(y) and cmp(x,y) or len(x)-len(y)) print'\n'.join(l)