k = int(eval(input()))

pre = 7 % k

for i in range(1, 10 ** 6):

    if pre == 0:

        print(i)

        quit()

    pre = (pre * 10 + 7) % k

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

num = 7 % k

for i in range(10 ** 6):

  if num == 0:

    print((i + 1))

    quit()

  num = (num * 10 + 7) % k

print((-1))

  

  
k = int(eval(input()))
pre = 7 % k
for i in range(1, 10**6):
    if pre == 0:
        print(i)
        quit()
    pre = (pre * 10 + 7) % k
print((-1))

k = int(eval(input()))
num = 7 % k
for i in range(10**6):
    if num == 0:
        print((i + 1))
        quit()
    num = (num * 10 + 7) % k
print((-1))

-pre = 7 % k -for i in range(1, 10**6): -    if pre == 0: -        print(i) +num = 7 % k +for i in range(10**6): +    if num == 0: +        print((i + 1)) -    pre = (pre * 10 + 7) % k +    num = (num * 10 + 7) % k