k = gets.chomp.to_i
i = 1
a = 7 % k
hazime = a
arr = [-1]
if k != 7
    until a == 0 
        a = (7 + a * 10) % k
        if a == hazime || i == k
            puts arr.shift
            exit
        end
        i += 1
    end
else
    puts "1"
end
puts i