s = int(input())
r=7
ret=-1
for a in range(1000000):
  if r % s == 0 :
    ret = a + 1
    break
  else:
    r=(r*10+7)%s
print(ret) s = int(input()) s int(input()) int input() input r=7 r 7 ret=-1 ret -1 for a in range(1000000):
  if r % s == 0 :
    ret = a + 1
    break
  else:
    r=(r*10+7)%s a range(1000000) range 1000000 if r % s == 0 :
    ret = a + 1
    break
  else:
    r=(r*10+7)%s r % s == 0 r % s r s 0 ret = a + 1 ret a + 1 a 1 break r=(r*10+7)%s r (r*10+7)%s r*10+7 r*10 r 10 7 s print(ret) print ret ret=-1 -1 ret r=(r*10+7)%s (r*10+7)%s r s = int(input()) int(input()) s ret = a + 1 a + 1 ret r=7 7 r
s = int(input())
r=7
ret=-1
for a in range(1000000):
  if r % s == 0 :
    ret = a + 1
    break
  else:
    r=(r*10+7)%s
print(ret)