import sys

K = int(eval(input()))



power = 7

SUM = 0



for i in range(1, 10 ** 6):

    SUM += power

    if SUM % K == 0:

        print(i)

        sys.exit()

    power *= 10

    power %= K



print((-1))
import sys

K = int(eval(input()))



L = 9 * K



if K % 7 == 0:

    L //= 7



power = 1



for i in range(1, 10 ** 6):

    power *= 10

    power %= L

    if power == 1:

        print(i)

        sys.exit()



print((-1))
import sys

K = int(eval(input()))
power = 7
SUM = 0
for i in range(1, 10**6):
    SUM += power
    if SUM % K == 0:
        print(i)
        sys.exit()
    power *= 10
    power %= K
print((-1))

import sys

K = int(eval(input()))
L = 9 * K
if K % 7 == 0:
    L //= 7
power = 1
for i in range(1, 10**6):
    power *= 10
    power %= L
    if power == 1:
        print(i)
        sys.exit()
print((-1))

-power = 7 -SUM = 0 +L = 9 * K +if K % 7 == 0: +    L //= 7 +power = 1 -    SUM += power -    if SUM % K == 0: +    power *= 10 +    power %= L +    if power == 1: -    power *= 10 -    power %= K