#include using namespace std; typedef long long ll; const int N = 1e4 + 10; int b[N]; int main() { cin.tie(0), cout.tie(0), ios::sync_with_stdio(false); int n; cin >> n; int w = 1, i = 1; while(i < n) { if(b[i]) { cout << -1; return 0; } int u = i, ans = 0; while(u) { if(u & 1) ans ++ ; u >>= 1; } b[i] = 1; if(i + ans <= n) i += ans; else i -= ans; w ++ ; } // 1 2 3 5 7 10 12 if(i != n) cout << -1; else cout << w; return 0; }