k = int(eval(input()))

rem = 7%k

alreadys = [False]*k

alreadys[rem] = True



ans = 1

while True:

    if rem == 0:

        print(ans)

        exit()

    ans += 1

    rem = (rem*10+7)%k

    if alreadys[rem]:

        print((-1))

        exit()

    alreadys[rem] = True
k = int(eval(input()))

rem = 7%k

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

    if rem == 0:

        print((i+1))

        break

    rem = (rem*10+7)%k

else:

    print((-1))
k = int(eval(input()))
rem = 7 % k
alreadys = [False] * k
alreadys[rem] = True
ans = 1
while True:
    if rem == 0:
        print(ans)
        exit()
    ans += 1
    rem = (rem * 10 + 7) % k
    if alreadys[rem]:
        print((-1))
        exit()
    alreadys[rem] = True

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

-alreadys = [False] * k -alreadys[rem] = True -ans = 1 -while True: +for i in range(10**6 + 1): -        print(ans) -        exit() -    ans += 1 +        print((i + 1)) +        break -    if alreadys[rem]: -        print((-1)) -        exit() -    alreadys[rem] = True +else: +    print((-1))