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