k = int(eval(input()))



if k % 2 == 0 or k % 5 == 0:

    print((-1))

    exit()

ans = 1

a = 7 % k

while a:

    a = a*10 + 7

    a %= k

    ans += 1

print(ans)
k = int(eval(input()))



if k % 2 == 0 or k % 5 == 0:

    print((-1))

else:

    a = 7 % k

    cnt = 1

    while a:

        a = (a*10 + 7) % k

        cnt += 1

    print(cnt)
k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit()
ans = 1
a = 7 % k
while a:
    a = a * 10 + 7
    a %= k
    ans += 1
print(ans)

k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
    a = 7 % k
    cnt = 1
    while a:
        a = (a * 10 + 7) % k
        cnt += 1
    print(cnt)

-    exit() -ans = 1 -a = 7 % k -while a: -    a = a * 10 + 7 -    a %= k -    ans += 1 -print(ans) +else: +    a = 7 % k +    cnt = 1 +    while a: +        a = (a * 10 + 7) % k +        cnt += 1 +    print(cnt)