#include #include #include #include #include using namespace std; int main() { int n; int masu = 1; int s = 0; int k; cin >> n; for (int i = 1; i <= 10000; i++) { if (masu == n) { cout << i ; break; } k = masu; for (int j = 1; j <= 20; j++) { s = k % 2 + s; k = k / 2 ; if (k == 0) { break; } } masu = s + masu; if (masu > n) { masu = masu - s*2; } s = 0; if (i == 10000) { cout << -1; } } }