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,L+1):

        a = (a * 10) % L

        if a == 1:

            print(i)

            return

    print((-1))

main()
#!python3.8

# -*- coding: utf-8 -*-

# abc174/abc174_c

import sys

 

s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in list(ss)]

ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]

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

i2n = lambda: int(i2s())

i2nn = lambda: s2nn(i2s())

ii2ss = lambda n: [i2s() for _ in range(n)]

ii2nn = lambda n: ss2nn(ii2ss(n))

ii2nnn = lambda n: ss2nnn(ii2ss(n))

 

def main():

    K = i2n()

    a = 0

    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')

    return



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, L + 1):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))


main()

#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    K = i2n()
    a = 0
    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")
    return


main()

+#!python3.8 +# -*- coding: utf-8 -*- +# abc174/abc174_c -input = sys.stdin.readline +s2nn = lambda s: [int(c) for c in s.split(" ")] +ss2nn = lambda ss: [int(s) for s in list(ss)] +ss2nnn = lambda ss: [s2nn(s) for s in list(ss)] +i2s = lambda: sys.stdin.readline().rstrip() +i2n = lambda: int(i2s()) +i2nn = lambda: s2nn(i2s()) +ii2ss = lambda n: [i2s() for _ in range(n)] +ii2nn = lambda n: ss2nn(ii2ss(n)) +ii2nnn = lambda n: ss2nnn(ii2ss(n)) -    K = int(eval(input())) -    if K % 2 == 0: -        print((-1)) -        return +    K = i2n() +    a = 0 -    for i in range(1, L + 1): +    for i in range(1, K + 10): -    print((-1)) +    print("-1") +    return