#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll X, v; cin >> X; for(int i = 0; i < 62; i++){ v = X ^ i; if(__builtin_popcountll(v) == i && v <= 2000000000000000000ll){ cout << v << '\n'; return 0; } } cout << -1 << '\n'; }