x = int(input()) base = 0 count = 0 for i in range(10,65): if x >> i & 1: base |= 1 << i count += 1 for i in range(1<<10): c = bin(i).count("1")+count n = base|i if n^c == x: print(n) exit() print(-1)