#include using namespace std; int main(){ long long X; cin >> X; long long N = -1; for (int i = 0; i < 62; i++){ if (__builtin_popcount(X ^ i) == i){ if (1 <= (X ^ i) && (X ^ i) <= 2000000000000000000){ N = X ^ i; } } } cout << N << endl; }