require 'set'

k = gets.to_i

answer = 1
rest = 7
mem = Set.new

loop do
  if rest >= k && rest % k == 0
    puts answer
    exit
  end
  rest = rest % k * 10 + 7
  unless mem.add?(rest)
    puts -1
    exit
  end
  answer += 1
end
