import io.StdIn.{readInt, readLine}
object Main extends App {
  val k = readInt
  
  if (k%2 == 0 || k%5 == 0) println("-1")
  else {

    var target = k
    var determined_digit = 0
    while (target != 0) {
      
      if (target%10==7) {
        while (target%10 == 7) {
          target = target/10
          determined_digit += 1
        }
      } else {
        while (target%10 != 7) {
          target = target + k
        }
      }

    }

    val result = determined_digit
    println(result)

  }
}