import scala.io.StdIn._

object Main extends App {
  val k = readInt()

  def solve(): Int = {
    var set = Set.empty[Int]
    var cnt = 1
    var x = 7%k
    while(!set(x)) {
      if(x == 0) return cnt
      else {
        set = set + x
        x = (x * 10 + 7) % k
        cnt += 1
      }
    }
    -1
  }

  println(solve())

}

