#include "bits/stdc++.h" using namespace std; int main() { int N; cin >> N; int i=1, n=14, ans=1; while (1) { 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++; //printf("%d\n",ans); if(i==N) break; if (ans > (int)1e3) { cout << -1 << endl; return 0; } } cout << ans << endl; }