x = int(input()) for m in range(100): n = x^m if bin(n).count("1")==m: print(n) exit() print(-1)