def calc(k):

    cur = 0

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

        cur *= 10

        cur += 7

        cur %= k

        if cur == 0:

            return i



    return -1





k = int(eval(input()))

print((calc(k)))
def calc(k):

    cur = 7 % k

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

        if cur == 0:

            return i

        else:

            cur *= 10

            cur += 7

            cur %= k

    return -1





k = int(eval(input()))

print((calc(k)))

def calc(k):
    cur = 0
    for i in range(1, 10**7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i
    return -1


k = int(eval(input()))
print((calc(k)))

def calc(k):
    cur = 7 % k
    for i in range(1, k + 1):
        if cur == 0:
            return i
        else:
            cur *= 10
            cur += 7
            cur %= k
    return -1


k = int(eval(input()))
print((calc(k)))

-    cur = 0 -    for i in range(1, 10**7): -        cur *= 10 -        cur += 7 -        cur %= k +    cur = 7 % k +    for i in range(1, k + 1): +        else: +            cur *= 10 +            cur += 7 +            cur %= k