#include int ri() { int n; scanf("%d", &n); return n; } int main() { int64_t x; std::cin >> x; for (int64_t i = std::max(0, x - 60); i <= x + 60; i++) { if ((i ^ __builtin_popcountll(i)) == x) { printf("%" PRId64 "\n", i); return 0; } } puts("-1"); return 0; }