K = int(eval(input()))

if K%2 == 0:

    print((-1))

elif K%5 == 0:

    print((-1))

else:

    res = 7

    for i in range(K):

        if res % K == 0:

            break

        res = (res * 10 + 7) % K

    print((i + 1))
K = int(eval(input()))

res = 7 % K

for i in range(K):

    if res == 0:

        ans = i+1

        break

    res = (res * 10 + 7) % K

if res != 0:

    ans = -1

print(ans)
K = int(eval(input()))
if K % 2 == 0:
    print((-1))
elif K % 5 == 0:
    print((-1))
else:
    res = 7
    for i in range(K):
        if res % K == 0:
            break
        res = (res * 10 + 7) % K
    print((i + 1))

K = int(eval(input()))
res = 7 % K
for i in range(K):
    if res == 0:
        ans = i + 1
        break
    res = (res * 10 + 7) % K
if res != 0:
    ans = -1
print(ans)

-if K % 2 == 0: -    print((-1)) -elif K % 5 == 0: -    print((-1)) -else: -    res = 7 -    for i in range(K): -        if res % K == 0: -            break -        res = (res * 10 + 7) % K -    print((i + 1)) +res = 7 % K +for i in range(K): +    if res == 0: +        ans = i + 1 +        break +    res = (res * 10 + 7) % K +if res != 0: +    ans = -1 +print(ans)