fun main() {
    val k = readInt()

    var n = 0
    var t = 1
    var count = 0
    while (true) {
        n = (n + 7 * t) % k
        t = (t * 10) % k
        count++
        if (n == 0) {
            println(count)
            return
        }
        if (count > k) {
            println(-1)
            return
        }
    }
}

private fun readInt() = readLine()!!.toInt()
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
