import sys



i2s = lambda: sys.stdin.readline().rstrip()

i2n = lambda: int(i2s())



def main():

    K = i2n()

    

    if K%2==0:

        print((-1))

        return

    

    if K % 7:

        L = 9*K

    else:

        L = 9*K//7

    a = 1

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

        a = (a * 10) % L

        if a == 1:

            print(i)

            return

    print((-1))

main()
import sys

input = sys.stdin.readline



def main():

    K = int(eval(input()))

    

    if K%2==0:

        print((-1))

        return

    

    if K % 7:

        L = 9*K

    else:

        L = 9*K//7

    a = 1

    for i in range(1,K+10):

        a = (a * 10) % L

        if a == 1:

            print(i)

            return

    print((-1))

main()
import sys

i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())


def main():
    K = i2n()
    if K % 2 == 0:
        print((-1))
        return
    if K % 7:
        L = 9 * K
    else:
        L = 9 * K // 7
    a = 1
    for i in range(1, L + 1):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))


main()

import sys

input = sys.stdin.readline


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


main()

-i2s = lambda: sys.stdin.readline().rstrip() -i2n = lambda: int(i2s()) +input = sys.stdin.readline -    K = i2n() +    K = int(eval(input())) -    for i in range(1, L + 1): +    for i in range(1, K + 10):