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