import sys



readline = sys.stdin.readline

readall = sys.stdin.read

ns = lambda: readline().rstrip()

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))

prn = lambda x: print(*x, sep='\n')



def solve():

    d = dict()

    k = ni()

    c = 7 % k

    x = d[c] = 1

    while True:

        c = (c * 10 + 7) % k

        if c in d:

            break

        x += 1

        d[c] = x

    print(d.get(0, -1))

    return



solve()

import sys



readline = sys.stdin.readline

readall = sys.stdin.read

ns = lambda: readline().rstrip()

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))

prn = lambda x: print(*x, sep='\n')



def solve():

    k = ni()

    c = 0

    for i in range(k):

        c = (c * 10 + 7) % k

        if c == 0:

            print(i+1)

            break

    else:

        print(-1)

    return



solve()

import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")


def solve():
    d = dict()
    k = ni()
    c = 7 % k
    x = d[c] = 1
    while True:
        c = (c * 10 + 7) % k
        if c in d:
            break
        x += 1
        d[c] = x
    print(d.get(0, -1))
    return


solve()

import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")


def solve():
    k = ni()
    c = 0
    for i in range(k):
        c = (c * 10 + 7) % k
        if c == 0:
            print(i + 1)
            break
    else:
        print(-1)
    return


solve()

-    d = dict() -    c = 7 % k -    x = d[c] = 1 -    while True: +    c = 0 +    for i in range(k): -        if c in d: +        if c == 0: +            print(i + 1) -        x += 1 -        d[c] = x -    print(d.get(0, -1)) +    else: +        print(-1)