#include using namespace std; int bitcount(int n){ int i=0; while(n>0){ if(n%2){ i++; } n/=2; } return i; } int main() { int N,now,mv,go,back; cin>>N; queue qu; bool frag[N+1]; for(int i=1;i<=N;i++){ frag[i]=false; } int count[N+1]; qu.push(1); count[1]=1; while(1){ now=qu.front(); qu.pop(); mv=bitcount(now); go=now+mv; back=now-mv; if(go<=N && !frag[go]){ qu.push(go); frag[go]=true; count[go]=count[now]+1; }else if(0