k = int(input())

t = 7
flag = True
for i in range(k):
  if t % k == 0:
    print(i + 1)
    flag = False
    break
  else:
    t = (t * 10 + 7) % k
if flag:
  print('-1') k = int(input()) k int(input()) int input() input t = 7 t 7 flag = True flag True for i in range(k):
  if t % k == 0:
    print(i + 1)
    flag = False
    break
  else:
    t = (t * 10 + 7) % k i range(k) range k if t % k == 0:
    print(i + 1)
    flag = False
    break
  else:
    t = (t * 10 + 7) % k t % k == 0 t % k t k 0 print(i + 1) print i + 1 i 1 flag = False flag False break t = (t * 10 + 7) % k t (t * 10 + 7) % k t * 10 + 7 t * 10 t 10 7 k if flag:
  print('-1') flag print('-1') print '-1' t = 7 7 t t = (t * 10 + 7) % k (t * 10 + 7) % k t k = int(input()) int(input()) k flag = True True flag flag = False False flag
k = int(input())

t = 7
flag = True
for i in range(k):
  if t % k == 0:
    print(i + 1)
    flag = False
    break
  else:
    t = (t * 10 + 7) % k
if flag:
  print('-1')