#include #include using namespace std; int movecount(int n){ int count = 0; while(n>0){ count += n%2; n /= 2; } return count; } int main(){ int dist[10001]; queue q; int N; cin>>N; for(int i=1; i<=N;i++){ dist[i]=-1; } q.push(1); dist[1] = 1; while(!q.empty()){ int now = q.front(); int move = movecount(q.front()); q.pop(); if((now-move)>=1){ if(dist[now-move]==-1){ dist[now-move] = dist[now]+1; q.push(now-move); } } if((now+move)<=N){ if(dist[now+move]==-1){ dist[now+move] = dist[now]+1; q.push(now+move); } } } cout<