K = gets.chomp.to_i
x = 7.modulo(K)
mods = [x]
(1..K).each do |i|
    if x == 0 then
        puts i
        exit
    end
    x = (x * 10 + 7).modulo(K)
    # if mods.include?(x) then
    #     puts -1
    #     exit
    # else
    #     mods.push(x)
    # end
end
puts -1