for x in map(int,open(0)):print(min((bin(x*y).count('1'),y)for i in range(x)for y in[(2**i+2**j)//x|1for j in range(25)])[1])
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page