K=int(input())

x=7%K
i=1
flag=0
for j in range(K+1):
  if x==0:
    print(i)
    flag=1
    break
  x=(10*x+7)%K
  i+=1


if flag==0:
  print(-1) K=int(input()) K int(input()) int input() input x=7%K x 7%K 7 K i=1 i 1 flag=0 flag 0 for j in range(K+1):
  if x==0:
    print(i)
    flag=1
    break
  x=(10*x+7)%K
  i+=1 j range(K+1) range K+1 K 1 if x==0:
    print(i)
    flag=1
    break
   x==0 x 0 print(i) print i flag=1 flag 1 break x=(10*x+7)%K x (10*x+7)%K 10*x+7 10*x 10 x 7 K i+=1 i 1 if flag==0:
  print(-1) flag==0 flag 0 print(-1) print -1 i=1 1 i K=int(input()) int(input()) K x=7%K 7%K x flag=0 0 flag flag=1 1 flag x=(10*x+7)%K (10*x+7)%K x i+=1 1 i
K=int(input())

x=7%K
i=1
flag=0
for j in range(K+1):
  if x==0:
    print(i)
    flag=1
    break
  x=(10*x+7)%K
  i+=1


if flag==0:
  print(-1)