N = 10**6+1
K = gets.to_i

n = 0
ans = 0
ok = false
for i in 1..N
    n = (n*10 + 7) % K
    ans += 1
    if n == 0
        ok = true
        break
    end
end

if ok
    puts ans
else
    puts "-1"
end

