N = int(input()) import sys for i in range(3,6): if i >= N: print(-1) exit() a = N - i if a != (a & -a): print(i) exit() print(-1)