k = int(input())

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

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