def f(K):

    sum = 0

    for i in range(K+1):

        sum += (pow(10, i, K)*7)

        sum %= K



        if sum == 0:

            return i+1

    return -1





K = int(eval(input()))



print((f(K)))

def f(K):

    sum = 0

    p10 = 1

    for i in range(K+1):

        sum += p10*7

        p10 *= 10

        p10 %= K

        sum %= K



        if sum == 0:

            return i+1

    return -1





K = int(eval(input()))



print((f(K)))

def f(K):
    sum = 0
    for i in range(K + 1):
        sum += pow(10, i, K) * 7
        sum %= K
        if sum == 0:
            return i + 1
    return -1


K = int(eval(input()))
print((f(K)))

def f(K):
    sum = 0
    p10 = 1
    for i in range(K + 1):
        sum += p10 * 7
        p10 *= 10
        p10 %= K
        sum %= K
        if sum == 0:
            return i + 1
    return -1


K = int(eval(input()))
print((f(K)))

+    p10 = 1 -        sum += pow(10, i, K) * 7 +        sum += p10 * 7 +        p10 *= 10 +        p10 %= K