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