import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val k = sc.nextInt()

  var l: Int
  if (k % 7 == 0) {
    l = 9 * k / 7
  } else {
    l = 9 * k
  }


  if (l % 2 == 0 || l % 5 == 0) {
    println(-1)
    return
  }

  var i = 1
  var tmp = 10L
  while (true) {
    if (tmp % l == 1L) {
      println(i)
      return
    }

    i++
    tmp = tmp % l * 10
  }

}