import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val k = sc.next().toLong()
        var a = 7L
        var n = 1
        while (true) {
            a %= k
            if (a == 0L) break
            a = a * 10 + 7
            if (n > 50000000) {
                pw.println("-1")
                return
            }
            n++
        }
        pw.println(n)
    }
}
