require "set"

def max(a, b); a < b ? b : a; end
def min(a, b); a < b ? a : b; end

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @k = gets.to_s.to_i
    @cnt = Set.new
  end

  def solve
    i = 1
    n = 7
    loop do
      return i if n % k == 0
      n = n * 10 + 7
      n %= k
      i += 1
      return -1 if @cnt.include?(n)
      @cnt << n
    end
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end
