#include #include using namespace std; int main(){ long long n,a,o=0; cin>>n; long long dp[n],b[n],c[n]; for(int i=0;i0){ b[i]+=a%2; a/=2; } } dp[0]=1; for(int i=0;idp[i]+1){ dp[i+b[i]]=dp[i]+1; c[i+b[i]]=1; o++; } } if(i+b[i]>0){ if(dp[i-b[i]]>dp[i]+1){ dp[i-b[i]]=dp[i]+1; c[i-b[i]]=1; o++; } } } } } if(dp[n-1]==10000)dp[n-1]=-1; cout<