K = int(eval(input()))

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

    print((-1))

    

else:

    if K % 7 == 0:

        L = 9 * K // 7

    else:

        L = 9 * K

    n = 1

    P = 10 % L

    while True:

        if P == 1:

            print(n)

            break

        n += 1

        P = (10 * P) % L
K = int(eval(input()))

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

    print((-1))

else:

    a = 1

    b = a % K

    i = 1

    while True:

        if (7*a) % K == 0:

            print(i)

            break

        else:

            a += (10*b) % K

            b = (10*b) % K

            i += 1 
K = int(eval(input()))
if K % 2 == 0 or K % 5 == 0:
    print((-1))
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

K = int(eval(input()))
if K % 2 == 0 or K % 5 == 0:
    print((-1))
else:
    a = 1
    b = a % K
    i = 1
    while True:
        if (7 * a) % K == 0:
            print(i)
            break
        else:
            a += (10 * b) % K
            b = (10 * b) % K
            i += 1

-    if K % 7 == 0: -        L = 9 * K // 7 -    else: -        L = 9 * K -    n = 1 -    P = 10 % L +    a = 1 +    b = a % K +    i = 1 -        if P == 1: -            print(n) +        if (7 * a) % K == 0: +            print(i) -        n += 1 -        P = (10 * P) % L +        else: +            a += (10 * b) % K +            b = (10 * b) % K +            i += 1