while True:
try:
x1 = int(input())
if x1 == 1 or x1 == 2:
print(-1)
elif (x1+1) % 2 == 0:
print(2)
elif x1 % 4 == 0:
print(3)
elif (x1-2) % 4 == 0:
print(4)
except:
break