# k = int(input())

K = eval(input())

k = int(K)

# if k%2 == 0:

#     print(-1)

#     exit()



# r7 = 7%k

r = 0

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

    r = (r*10 + 7)%k



    # print('r {} i {}'.format(r,i))

    if r == 0:

        print(i)

        exit()

    # print(n)

print((-1))

k = int(eval(input()))

r = 0

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

    r = (r*10 + 7)%k

    if r == 0:

        print(i)

        exit()

print((-1))

# k = int(input())
K = eval(input())
k = int(K)
# if k%2 == 0:
#     print(-1)
#     exit()
# r7 = 7%k
r = 0
for i in range(1, k * 10):
    r = (r * 10 + 7) % k
    # print('r {} i {}'.format(r,i))
    if r == 0:
        print(i)
        exit()
    # print(n)
print((-1))

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

-# k = int(input()) -K = eval(input()) -k = int(K) -# if k%2 == 0: -#     print(-1) -#     exit() -# r7 = 7%k +k = int(eval(input())) -for i in range(1, k * 10): +for i in range(1, k + 1): -    # print('r {} i {}'.format(r,i)) -    # print(n)