#include using namespace std; int takeSpeed(int n){ int i(1), c(0), tmp(0); while(n > 0){ c += n%2; n /= 2; } return c; } int main(){ int N, pos(1), speed(0), c(1); cin >> N; while(pos != N){ if(c > N){ c= -1; break; } speed = takeSpeed(pos); pos += speed; c++; } cout << c << endl; return 0; }