#include using namespace std; int count(int n) { int i, c = 0, b = 1; for (i=0; i<16; i++) { b *= 2; if (b > n) break; } while (1) { b /= 2; if (i-- < 0 || !n) break; if (n - b >= 0) { n -= b; c++; } } return c; } int main() { int i=1, n, c, way=1, b; bool flag = false, loopCheck = false; cin >> n; while (i <= n) { if (i == n) { flag = true; break; } c = count(i); if (i + c > n) { i -= c; if (loopCheck) { if (i == b) break; } else { b = i; loopCheck = true; } } else { i += c; } way++; } if (flag) { cout << way << endl; } else { cout << -1 << endl; } return 0; }