n = gets.to_i

if n % 2 == 0 || n % 5 == 0
  puts -1
  return
end

n = n / 7 if n % 7 == 0

x = 0
count = 0
n.times do
  x = (x * 10 + 7) % n
  count += 1
  break if x == 0
end

puts x == 0 ? count : -1
