k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
else:
  print(-1) k=int(input()) k int(input()) int input() input k *= 9 k 9 amari = 63 amari 63 for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
else:
  print(-1) i range(1, 10 ** 6 + 1) range 1 10 ** 6 + 1 10 ** 6 10 6 1 amari %= k amari k if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63 amari == 0 amari 0 print(i) print i break amari = amari * 10 + 63 amari amari * 10 + 63 amari * 10 amari 10 63 print(-1) print -1 amari = 63 63 amari amari %= k k amari k *= 9 9 k k=int(input()) int(input()) k amari = amari * 10 + 63 amari * 10 + 63 amari
k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
else:
  print(-1)