# 看了大佬的思路,重点还是找规律啊
# 看了大佬的思路,重点还是找规律啊 while 1: try: n = int(input()) g = [2,3,2,4] if n<3: print(-1) else: print(g[(n-2)%4-1]) except: break