#include using namespace std; #define rep(i, n) for(ll i = 0; i < ll(n); i++) using ll = long long; using P = pair; int main() { cin.tie(0); ios_base::sync_with_stdio(false); ll x; cin >> x; rep(i, 64) { if (i == __builtin_popcount(x ^ i)) { cout << (x ^ i) << endl; return 0; } } cout << -1 << endl; return 0; }