import sys

K=int(eval(input()))



if K%2==0 or K%5==0:

  print((-1))

  sys.exit(0)



k_mod=0

seven_k=0

for i in range(1,K+1):

  k_mod=10*k_mod+7

  k_mod%=K

  if k_mod==0:

    print(i)

    break

else:

  print((-1))
K=int(eval(input()))



k_mod=0

for i in range(1,K+1):

  k_mod=(10*k_mod+7)%K

  if k_mod==0:

    print(i)

    break

else:

  print((-1))
import sys

K = int(eval(input()))
if K % 2 == 0 or K % 5 == 0:
    print((-1))
    sys.exit(0)
k_mod = 0
seven_k = 0
for i in range(1, K + 1):
    k_mod = 10 * k_mod + 7
    k_mod %= K
    if k_mod == 0:
        print(i)
        break
else:
    print((-1))

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

-import sys - -if K % 2 == 0 or K % 5 == 0: -    print((-1)) -    sys.exit(0) -seven_k = 0 -    k_mod = 10 * k_mod + 7 -    k_mod %= K +    k_mod = (10 * k_mod + 7) % K