k = gets.chomp.to_i

if k % 5 == 0 || k % 2 == 0
  puts '-1'
else
  m = k % 7 == 0 ? k / 7 * 9 : k * 9

  s = 0
  1.upto(m - 1) do |i|
    s = (s * 10 + 7) % k
    if s == 0
      puts i
      break
    end
  end
end
