X = int(input()) limit = 2*10**18 for m in range(0, 62): n = m^X if n <= limit and n.bit_count() == m: exit(print(n)) print(-1)