K = int(input())
n = 7
c = 0
while c <= K:
  n %= K
  c += 1
  if n == 0:
    print(c)
    exit()
  n = n * 10 + 7
print(-1) K = int(input()) K int(input()) int input() input n = 7 n 7 c = 0 c 0 while c <= K:
  n %= K
  c += 1
  if n == 0:
    print(c)
    exit()
  n = n * 10 + 7 c <= K c K n %= K n K c += 1 c 1 if n == 0:
    print(c)
    exit()
   n == 0 n 0 print(c) print c exit() exit n = n * 10 + 7 n n * 10 + 7 n * 10 n 10 7 print(-1) print -1 c += 1 1 c n = n * 10 + 7 n * 10 + 7 n K = int(input()) int(input()) K n = 7 7 n c = 0 0 c n %= K K n
K = int(input())
n = 7
c = 0
while c <= K:
  n %= K
  c += 1
  if n == 0:
    print(c)
    exit()
  n = n * 10 + 7
print(-1)