#include "bits/stdc++.h" using namespace std; int main() { int N; cin >> N; int i=1, n=14, ans=1; vector c(N+1,0); while (i!=N) { int cnt=0; //cout << bitset<10>(i) << endl; for (int bit = 0; bit < n; bit++) { if (i & (1 << bit)) { cnt++; } } //cout <<" "<< cnt <<" "<< i+cnt << endl; if ((i + cnt) > N) { i -= cnt; } else { i += cnt; } //cout <<" "<< i << endl; ans++; c[i]++; if (c[i] >= 2) { cout << -1 << endl; return 0; } } cout << ans << endl; }