local k=io.read("n")
if k%2==0 or k%5==0 then
    print(-1)
else
    local mul=1
    local mod=10
    local div=(k%7==0 and 9*k//7 or 9*k)
    while mod%div~=0 do
        mod=mod*mul%div
        mul=mul+1
    end
    print(mul)
end 