def c_repsept():

    K = int(eval(input()))



    if (K % 2 == 0 or K % 5 == 0):

        return -1  # repsept の因数に 2, 5 はない



    repsept = 7 % K

    count = 1

    while repsept % K !=0:

        repsept = ((repsept * 10) + 7) % K

        count += 1

    return count



print((c_repsept()))
def c_repsept():

    K = int(eval(input()))



    L = 9 * K // 7 if K % 7 == 0 else 9 * K

    if L % 2 == 0 or L % 5 == 0:

        return -1



    remainder = 1

    for n in range(1, L + 1):

        remainder = (10 * remainder) % L

        if remainder == 1:

            return n

    return -1



print((c_repsept()))
def c_repsept():
    K = int(eval(input()))
    if K % 2 == 0 or K % 5 == 0:
        return -1  # repsept の因数に 2, 5 はない
    repsept = 7 % K
    count = 1
    while repsept % K != 0:
        repsept = ((repsept * 10) + 7) % K
        count += 1
    return count


print((c_repsept()))

def c_repsept():
    K = int(eval(input()))
    L = 9 * K // 7 if K % 7 == 0 else 9 * K
    if L % 2 == 0 or L % 5 == 0:
        return -1
    remainder = 1
    for n in range(1, L + 1):
        remainder = (10 * remainder) % L
        if remainder == 1:
            return n
    return -1


print((c_repsept()))

-    if K % 2 == 0 or K % 5 == 0: -        return -1  # repsept の因数に 2, 5 はない -    repsept = 7 % K -    count = 1 -    while repsept % K != 0: -        repsept = ((repsept * 10) + 7) % K -        count += 1 -    return count +    L = 9 * K // 7 if K % 7 == 0 else 9 * K +    if L % 2 == 0 or L % 5 == 0: +        return -1 +    remainder = 1 +    for n in range(1, L + 1): +        remainder = (10 * remainder) % L +        if remainder == 1: +            return n +    return -1