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_totient():

    def euler_phi(n):

        """正整数 n に対して、n と互いに素な n 以下の正整数の個数"""

        ret = n

        for i in range(2, int(n**0.5) + 1):

            if n % i == 0:

                ret = ret // i * (i - 1)

                while n % i == 0:

                    n //= i

        if n > 1:

            ret -= ret // n

        return ret



    def divisor_list(n):

        """n の正の約数のリスト"""

        ret = set()

        for k in range(1, int(n**0.5) + 1):

            if n % k == 0:

                ret.update({k, n // k})

        return sorted(ret)



    K = int(eval(input()))

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



    for d in divisor_list(euler_phi(L)):

        if pow(10, d, L) == 1:

            return d

    return -1



print((c_repsept_totient()))
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_totient():
    def euler_phi(n):
        """正整数 n に対して、n と互いに素な n 以下の正整数の個数"""
        ret = n
        for i in range(2, int(n**0.5) + 1):
            if n % i == 0:
                ret = ret // i * (i - 1)
                while n % i == 0:
                    n //= i
        if n > 1:
            ret -= ret // n
        return ret

    def divisor_list(n):
        """n の正の約数のリスト"""
        ret = set()
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.update({k, n // k})
        return sorted(ret)

    K = int(eval(input()))
    L = 9 * (K // 7 if K % 7 == 0 else K)
    for d in divisor_list(euler_phi(L)):
        if pow(10, d, L) == 1:
            return d
    return -1


print((c_repsept_totient()))

-def c_repsept(): +def c_repsept_totient(): +    def euler_phi(n): +        """正整数 n に対して、n と互いに素な n 以下の正整数の個数""" +        ret = n +        for i in range(2, int(n**0.5) + 1): +            if n % i == 0: +                ret = ret // i * (i - 1) +                while n % i == 0: +                    n //= i +        if n > 1: +            ret -= ret // n +        return ret + +    def divisor_list(n): +        """n の正の約数のリスト""" +        ret = set() +        for k in range(1, int(n**0.5) + 1): +            if n % k == 0: +                ret.update({k, n // k}) +        return sorted(ret) + -    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 +    L = 9 * (K // 7 if K % 7 == 0 else K) +    for d in divisor_list(euler_phi(L)): +        if pow(10, d, L) == 1: +            return d -print((c_repsept())) +print((c_repsept_totient()))