k=int(input())
l=[0]*k
x=7%k
s=-1
for c in range(k):
    if x==0:
        s=c+1
        break
    if l[x]==1:
        break
    l[x]=1
    x=(10*x+7)%k
print(s) k=int(input()) k int(input()) int input() input l=[0]*k l [0]*k [0] 0 k x=7%k x 7%k 7 k s=-1 s -1 for c in range(k):
    if x==0:
        s=c+1
        break
    if l[x]==1:
        break
    l[x]=1
    x=(10*x+7)%k c range(k) range k if x==0:
        s=c+1
        break
     x==0 x 0 s=c+1 s c+1 c 1 break if l[x]==1:
        break
     l[x]==1 l[x] l x 1 break l[x]=1 l[x] l x 1 x=(10*x+7)%k x (10*x+7)%k 10*x+7 10*x 10 x 7 k print(s) print s s=-1 -1 s x=(10*x+7)%k (10*x+7)%k x l=[0]*k [0]*k l s=c+1 c+1 s x=7%k 7%k x k=int(input()) int(input()) k
k=int(input())
l=[0]*k
x=7%k
s=-1
for c in range(k):
    if x==0:
        s=c+1
        break
    if l[x]==1:
        break
    l[x]=1
    x=(10*x+7)%k
print(s)