while 1:
    try:
        n=int(input())
        if n<3:
            print(-1)
        else:
            l=[2,3,2,4]
            print(l[(n-2)%4-1])
    except:
        break