import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {

    val k = readInt()

    var mod = 0
    var ok = false
    for (i in 0 until 10_000_000) {
        mod = (10 * mod + 7) % k
        if (mod == 0) {
            println(i + 1)
            ok = true
            break
        }
    }

    if (!ok) {
        println(-1)
    }

//    val (n, queryCount) = readIntArray(2)
//    val a = readIntArray(n)
//
//    val segment = Array(4*n) { mutableSetOf<Int>()}
//
//    fun build(v: Int, left: Int, right: Int) {
//        if (left == right) {
//            segment[v].add(a[left])
//        } else {
//            val mid = left + (right - left) / 2
//
//            val s1 = build(2*v + 1, left, mid)
//            val s2 = build(2*v + 2, mid + 1, right)
//            segment[v].addAll(segment[2*v + 1])
//            segment[v].addAll(segment[2*v + 2])
//        }
//    }
//
//    build(0, 0, n - 1)
//
//    fun query(v: Int, left: Int, right: Int, queryLeft: Int, queryRight: Int): Set<Int> {
//        if (left == queryLeft && right == queryRight) {
//            return segment[v]
//        }
//
//        val mid = left + (right - left) / 2
//        if (queryRight <= mid) {
//            return query(2 * v + 1, left, mid, queryLeft, queryRight)
//        }
//
//        if (queryLeft > mid) {
//            return query(2* v + 2, mid + 1, right, queryLeft, queryRight)
//        }
//
//        val result = mutableSetOf<Int>()
//        result.addAll(query(2*v + 1, left, mid, queryLeft, mid))
//        result.addAll(query(2*v + 2, mid + 1, right, mid + 1, queryRight))
//        return result
//    }
//
//    for (query in 0 until queryCount) {
//        val (a, b) = readIntArray(2)
//        println(query(0, 0, n -1, a - 1, b - 1).size)
//    }
}

Measured memory_bytes: 34132