K = gets.to_i

case
when K == 7
  puts 1
when K%2 == 0 || K%5 == 0
  puts -1
else
  m = [nil, 7%K]
  (2 .. 10**6).each do |n|
    m[n] = (m[n - 1]*10 + 7)%K
    (puts n; exit) if m[n] == 0
  end
  puts -1
end