k=int(input())
a=0
for i in range(k):
  a+=7*pow(10,i,k)
  a%=k
  if a==0:
    print(i+1)
    exit()
print(-1) k=int(input()) k int(input()) int input() input a=0 a 0 for i in range(k):
  a+=7*pow(10,i,k)
  a%=k
  if a==0:
    print(i+1)
    exit() i range(k) range k a+=7*pow(10,i,k) a 7*pow(10,i,k) 7 pow(10,i,k) pow 10 i k a%=k a k if a==0:
    print(i+1)
    exit() a==0 a 0 print(i+1) print i+1 i 1 exit() exit print(-1) print -1 a=0 0 a k=int(input()) int(input()) k a%=k k a a+=7*pow(10,i,k) 7*pow(10,i,k) a
k=int(input())
a=0
for i in range(k):
  a+=7*pow(10,i,k)
  a%=k
  if a==0:
    print(i+1)
    exit()
print(-1)