fun main() {
//    a()
//    b()
    c()
}

fun c() {
    val k = readLine()!!.toInt()
    val l = if (k.rem(7) == 0) 9 * k / 7 else 9 * k
    var tenPowerMod = 1
    for (i in 1..9000000) {
        tenPowerMod = (tenPowerMod * 10) % l
        if (tenPowerMod == 1) {
            println(i)
            return
        }
    }
    println(-1)
}