#include int fnBitCount(int); int main(void){ int N; int location=1; int bit=0; int times=1; scanf("%d",&N); while(location != N) { bit = fnBitCount(location); if((bit+location) <= N) location += bit; else location -= bit; times++; if(times >= 10000){ printf("-1"); break; } } if(times < 10000) printf("%d",times); return 0; } int fnBitCount(int n) { int bit_counter=0; while(n>=1) { if(n%2==1) bit_counter++; n/=2; } return bit_counter; }