import math n=int(input()) dp=[False]*(n+1) table=[-1]*(n+1) def fun(index): root=index if index==n: return 0 if index<=0 or n0): if index&1: count+=1 index=index>>1 dp[root]=True ret=min(1+fun(root+count),1+fun(root-count)) dp[root]=False table[root]=ret return ret sum=fun(1)+1 print(-1 if sum==math.inf else sum)