while True:
try:
n = int(input())
# 误区!!!把三角形求出来再去找偶数在数据量大到时候会超时
# array = [[0] * (2 * n - 1) for i in range(n)]
# for i in range(n):
# array[i][n-1-i] = 1
# array[i][i-n] = 1
# for i in range(1, n):
# for j in range(1, 2 * n - 2):
# array[i][j] = array[i-1][j-1] + array[i-1][j] + array[i-1][j+1]
# for x in array[n-1]:
# if x % 2 == 0:
# print(array[n-1].index(x) + 1)
# break
# else:
# print(-1)
if n <= 2:
print(-1)
elif (n-2) % 2 == 1:
print(2)
elif n % 4 == 0:
print(3)
elif (n-2) % 4 == 0:
print(4)
except:
break
try:
n = int(input())
# 误区!!!把三角形求出来再去找偶数在数据量大到时候会超时
# array = [[0] * (2 * n - 1) for i in range(n)]
# for i in range(n):
# array[i][n-1-i] = 1
# array[i][i-n] = 1
# for i in range(1, n):
# for j in range(1, 2 * n - 2):
# array[i][j] = array[i-1][j-1] + array[i-1][j] + array[i-1][j+1]
# for x in array[n-1]:
# if x % 2 == 0:
# print(array[n-1].index(x) + 1)
# break
# else:
# print(-1)
if n <= 2:
print(-1)
elif (n-2) % 2 == 1:
print(2)
elif n % 4 == 0:
print(3)
elif (n-2) % 4 == 0:
print(4)
except:
break