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