K = int(eval(input()))

num = 0

for i in range(1000001):

    num += 7 * pow(10, i, K)

    num %= K

    if num == 0:

        print((i + 1))

        break

else:

    print((-1))

def solve(K):

    cur = 0

    tens = 1

    for i in range(1_000_001):

        cur += 7 * tens

        cur %= K

        if cur == 0:

            return i + 1

        tens *= 10

        tens %= K

    else:

        return -1





print((solve(int(eval(input())))))

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

def solve(K):
    cur = 0
    tens = 1
    for i in range(1_000_001):
        cur += 7 * tens
        cur %= K
        if cur == 0:
            return i + 1
        tens *= 10
        tens %= K
    else:
        return -1


print((solve(int(eval(input())))))

-K = int(eval(input())) -num = 0 -for i in range(1000001): -    num += 7 * pow(10, i, K) -    num %= K -    if num == 0: -        print((i + 1)) -        break -else: -    print((-1)) +def solve(K): +    cur = 0 +    tens = 1 +    for i in range(1_000_001): +        cur += 7 * tens +        cur %= K +        if cur == 0: +            return i + 1 +        tens *= 10 +        tens %= K +    else: +        return -1 + + +print((solve(int(eval(input())))))