def main():

    K = int(eval(input()))

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

        return -1



    if K % 7 == 0:

        L = K * 9 // 7

    else:

        L = K * 9

    

    for i in range(1, 10000000):

        x = pow(10, i, L)

        if x == 1:

            return i

    else:

        return -1





if __name__ == "__main__":

    ans = main()

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

if k==7 or k==1:

    print((1))

else:

    a=7

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

        a=10*a+7

        if a%k==0:

            print((i+1))

            break

        else:

            a=a%k

    else:

        print((-1))
def main():
    K = int(eval(input()))
    if K % 2 == 0 or K % 5 == 0:
        return -1
    if K % 7 == 0:
        L = K * 9 // 7
    else:
        L = K * 9
    for i in range(1, 10000000):
        x = pow(10, i, L)
        if x == 1:
            return i
    else:
        return -1


if __name__ == "__main__":
    ans = main()
    print(ans)

k = int(eval(input()))
if k == 7 or k == 1:
    print((1))
else:
    a = 7
    for i in range(1, 10**6):
        a = 10 * a + 7
        if a % k == 0:
            print((i + 1))
            break
        else:
            a = a % k
    else:
        print((-1))

-def main(): -    K = int(eval(input())) -    if K % 2 == 0 or K % 5 == 0: -        return -1 -    if K % 7 == 0: -        L = K * 9 // 7 +k = int(eval(input())) +if k == 7 or k == 1: +    print((1)) +else: +    a = 7 +    for i in range(1, 10**6): +        a = 10 * a + 7 +        if a % k == 0: +            print((i + 1)) +            break +        else: +            a = a % k -        L = K * 9 -    for i in range(1, 10000000): -        x = pow(10, i, L) -        if x == 1: -            return i -    else: -        return -1 - - -if __name__ == "__main__": -    ans = main() -    print(ans) +        print((-1))