

import scala.collection.mutable
import scala.io.StdIn
import scala.math
import scala.util.control.Breaks


object Main extends App {
  val b = new Breaks
  val k = StdIn.readLine().toInt

  val factorized = factorizePrime(k)

  val exist = factorized.map(solvePrimeUpperLimit(_)).forall(_.nonEmpty)
  var out = -1
  if(exist){
    var sevens = BigInt(0)
    b.breakable{
      for(i <- 1 to k){
        sevens = 10 * sevens + 7
        if(sevens % k == 0){
          out = i
          b.break()
        }
      }
    }
  }

  println(out)

  def factorizePrime(n:Int):List[Int] ={
    var num = n
    var seq = List[Int]()
    for(i <- 2 to math.sqrt(n).toInt){
      while(num % i == 0){
        num = num / i
        seq = i +: seq

      }

    }

    seq
  }

  def solvePrimeUpperLimit(p:Int):Option[Int]={
    p match{
      case 2 => None
      case 3 => Some(3)
      case 5 => None
      case _ => Some(p-1)
    }
  }
}






