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