object Main {
  def main(args: Array[String]): Unit = {
    val num = scala.io.StdIn.readInt

    if( num%2 == 0 || num%5 == 0 ) println( -1 )
    else {
      var check = 7
      var count = 1
      var check_num = Array.empty[ Int ]
      while( check%num != 0 && !check_num.contains( check%num )) {
        count += 1
        check_num = check_num :+ check%num
        check = ( check%num )*10 + 7
      }
      if( check%num != 0 ) println( -1 )
      else                 println( count )
    }
  }
}