K=int(eval(input()))



if K%2==0:

    print((-1))

    exit(0)

    

ans=[0]*(pow(10,6)+1)

ans[0]=0



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

    ans[i]=(ans[i-1]*10+7)%K

    if ans[i]==0:

        print(i)

        exit(0)



print((-1))
import functools



K=int(eval(input()))

 

if K%2==0:

    print((-1))

    exit(0)



mod=0



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

    mod=(mod*10+7)%K

    if mod==0:

        print(i)

        exit(0)

        

print((-1))
K = int(eval(input()))
if K % 2 == 0:
    print((-1))
    exit(0)
ans = [0] * (pow(10, 6) + 1)
ans[0] = 0
for i in range(1, pow(10, 6)):
    ans[i] = (ans[i - 1] * 10 + 7) % K
    if ans[i] == 0:
        print(i)
        exit(0)
print((-1))

import functools

K = int(eval(input()))
if K % 2 == 0:
    print((-1))
    exit(0)
mod = 0
for i in range(1, pow(10, 6)):
    mod = (mod * 10 + 7) % K
    if mod == 0:
        print(i)
        exit(0)
print((-1))

+import functools + -ans = [0] * (pow(10, 6) + 1) -ans[0] = 0 +mod = 0 -    ans[i] = (ans[i - 1] * 10 + 7) % K -    if ans[i] == 0: +    mod = (mod * 10 + 7) % K +    if mod == 0: