N = int(input()) a = 1 c = 0 while a < N: for b in bin(a): if b == "1": a += 1 c += 1 if a == N: print(a) else: print(-1)