K = gets.to_i

i = 1
mod = 0
plus_mod = 7 % K

loop do
  if K % 2 == 0 || K % 5 == 0
    puts -1
    break
  end
  mod = (mod + plus_mod) % K

  if mod == 0
    puts i
    break
  end
  i += 1
  plus_mod = (plus_mod * 10) % K
end
