k = gets.to_i

flg = Array.new(k,false)

now =7%k
i = 0
while i+=1 do
    if now==0 then
        puts i
        return
    end
    break if flg[now]
    flg[now]=true
    now = (now*10+7)%k
end

puts -1