import sys
sys.setrecursionlimit(10**8)

K = int(input())

for i in [2,5]:
    if K%i==0:
        print(-1)
        exit()
t = 0
for i in range(K):
    t = (t*10+7)%K
    if t == 0:
        print(i+1)
        exit()
print(-1) import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 K = int(input()) K int(input()) int input() input for i in [2,5]:
    if K%i==0:
        print(-1)
        exit() i [2,5] 2 5 if K%i==0:
        print(-1)
        exit() K%i==0 K%i K i 0 print(-1) print -1 exit() exit t = 0 t 0 for i in range(K):
    t = (t*10+7)%K
    if t == 0:
        print(i+1)
        exit() i range(K) range K t = (t*10+7)%K t (t*10+7)%K t*10+7 t*10 t 10 7 K if t == 0:
        print(i+1)
        exit() t == 0 t 0 print(i+1) print i+1 i 1 exit() exit print(-1) print -1 t = 0 0 t K = int(input()) int(input()) K t = (t*10+7)%K (t*10+7)%K t
import sys
sys.setrecursionlimit(10**8)

K = int(input())

for i in [2,5]:
    if K%i==0:
        print(-1)
        exit()
t = 0
for i in range(K):
    t = (t*10+7)%K
    if t == 0:
        print(i+1)
        exit()
print(-1)