# frozen_string_literal: true

N = gets.chomp.to_i

L = if N % 7 == 0
      (9 * N) / 7
    else
      9 * N
    end

num = 10**1 % L

(1..10**6).each do |n|
  if num - 1 == 0
    puts n
    exit
  end
  num = num * 10 % L
end

puts -1
