#include using namespace std; int main(){ int n;cin>>n;vector A(n+1,-1);queue> Q;Q.push({1,1}); while(!Q.empty()){ auto[x,y]=Q.front();Q.pop(); if(A[x]==-1){ A[x]=y; if(x==n)break; int z=__builtin_popcount(x); if(x-z>0)Q.push({x-z,y+1}); if(x+z<=n)Q.push({x+z,y+1}); } } cout<