import sys 

from collections import defaultdict

sys.setrecursionlimit(10**6)

MOD = 10**9+7 

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

K = int(readline())

a = defaultdict(int)

cnt = 0

N = 7

while True:

    cnt += 1

    s = N % K

    if s == 0:

        print(cnt)

        sys.exit()

    if s in a:

        print((-1))

        sys.exit()

    a[s] = 1

    N += pow(10,cnt,K)*7 

    N %= K
# -*- coding: utf-8 -*-

import sys 

from collections import defaultdict

sys.setrecursionlimit(10**6)

MOD = 10**9+7 

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

K = int(readline())

cnt = 0

N = 7

for i in range(K+1):

    if N % K == 0:

        print((i+1))

        sys.exit()

    N = (N*10+7) % K

print((-1))
import sys
from collections import defaultdict

sys.setrecursionlimit(10**6)
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
K = int(readline())
a = defaultdict(int)
cnt = 0
N = 7
while True:
    cnt += 1
    s = N % K
    if s == 0:
        print(cnt)
        sys.exit()
    if s in a:
        print((-1))
        sys.exit()
    a[s] = 1
    N += pow(10, cnt, K) * 7
    N %= K

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

sys.setrecursionlimit(10**6)
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
K = int(readline())
cnt = 0
N = 7
for i in range(K + 1):
    if N % K == 0:
        print((i + 1))
        sys.exit()
    N = (N * 10 + 7) % K
print((-1))

+# -*- coding: utf-8 -*- -a = defaultdict(int) -while True: -    cnt += 1 -    s = N % K -    if s == 0: -        print(cnt) +for i in range(K + 1): +    if N % K == 0: +        print((i + 1)) -    if s in a: -        print((-1)) -        sys.exit() -    a[s] = 1 -    N += pow(10, cnt, K) * 7 -    N %= K +    N = (N * 10 + 7) % K +print((-1))