#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 998244353; signed main() { ios::sync_with_stdio(false); cin.tie(0); int X; cin >> X; for (int i = max(1LL, X - 2000000); i <= X + 2000000; i++) { int cnt = 0; for (int j = 0; j < 62; j++) { if (i >> j & 1) { cnt++; } } if ((i ^ cnt) == X) { cout << i << endl; return 0; } } cout << -1 << endl; return 0; }