import List main=interact$unlines.sortBy((.g).compare.g).lines n+1#x|x<2=n|odd x=x-n^99|0<1=n#div x 2 g=(9#).read