def f(n) res=0 while n>0 if n%2==1 then res+=1 end n/=2 end return res end n=STDIN.gets.to_i dp=Array.new(n+1,-1) bs=[1] dp[1]=1 while bs.empty? == false a=bs.shift p1=a-f(a) p2=a+f(a) if 0