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