k = gets.to_i
s = 7
counter = 0
loop do
  if counter >= k
    puts '-1'
    break
  end
  if s % k == 0
    puts counter + 1
    break
  end

  counter += 1
  s *= 10 % k
  s %= k
  s += 7 % k
  s %= k
end