#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 < 60; i++){ v = X ^ i; if(__builtin_popcountll(v) == i && v >= 1){ cout << v << '\n'; return 0; } } cout << -1 << '\n'; }