#include #include using namespace std; int count_one(int n){ int count = 0; while(n > 0){ if(n % 2 == 1) count++; n /= 2; } return count; } int main(){ int N; cin >> N; int np = 1;//now_position int count = 1; vector pathed(N,0); while(true){ int step = count_one(np); np += step; count++; if(np == N) break; if(np > N) np -= step+step; if(pathed.at(np) == 2){ count = -1; break; } pathed.at(np) += 1; } cout << count << endl; }