object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val k = sc.nextInt()
  val res = Array.fill(k)(false)

  var i = 0
  var r = 7 % k
  res(r) = true
  var continue = true
  while (continue) {
    r = (((r * 10) % k) + 7 % k) % k
    if (res(r)) {
      continue = false
    } else {
      res(r) = true
    }
    i += 1
  }

  println(if (res(0)) i else -1)
}
