k = gets.chomp.to_i
a = 0
i = 0
arr = [k+1]
mod = k+1
until mod == 0
    a = 7 + 10 * a #7,77..を書いた
    mod = a % k
    if arr.include?(mod) || i == k
        puts "-1"
        exit
    end
    arr << mod 
    i += 1
end
puts i
