k=int(input())
flag=0
s=0
for i in range(1,9*k):
   s+=7
   s%=k
   if s==0:
       flag=i
       break
   s*=10
    
if flag:
    print(flag)
else:
    print(-1) k=int(input()) k int(input()) int input() input flag=0 flag 0 s=0 s 0 for i in range(1,9*k):
   s+=7
   s%=k
   if s==0:
       flag=i
       break
   s*=10
     i range(1,9*k) range 1 9*k 9 k s+=7 s 7 s%=k s k if s==0:
       flag=i
       break
    s==0 s 0 flag=i flag i break s*=10 s 10 if flag:
    print(flag)
else:
    print(-1) flag print(flag) print flag print(-1) print -1 flag=0 0 flag s%=k k s k=int(input()) int(input()) k s+=7 7 s flag=i i flag s=0 0 s s*=10 10 s
k=int(input())
flag=0
s=0
for i in range(1,9*k):
   s+=7
   s%=k
   if s==0:
       flag=i
       break
   s*=10
    
if flag:
    print(flag)
else:
    print(-1)
