while True:
try:
n = int(input())
if n > 2 and n % 2 == 0:
if n % 4 == 0:
print(3)
else:
print(4)
elif n > 2 and n % 2 == 1:
print(2)
else:
print(-1)
except:
break