from collections import deque N=int(input()) a=[0]*10001 for i in range(1,10001): a[i]=i.bit_count() q=deque([]) q.append(1) dist=[-1]*(N+1) dist[1]=1 while q: v=q.popleft() g=a[v] if 0