/* -*- coding: utf-8 -*- * * 1450.cc: No.1450 nahco314's First Problem - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int BN = 61; /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ inline int bnum(ll a) { int c = 0; for (; a > 0; a >>= 1) c += (a & 1); return c; } /* main */ int main() { ll x; scanf("%lld", &x); for (int m = 0; m < BN; m++) { ll n = x ^ m; if (bnum(n) == m) { printf("%lld\n", n); return 0; } } puts("-1"); return 0; }