k = int(input())
ans = 0
s = 7

for i in range(1, 10**6 + 1):
    s %= k
    if s == 0:
        print(i)
        exit()
    s = s*10 +7

print(-1)  k = int(input()) k int(input()) int input() input ans = 0 ans 0 s = 7 s 7 for i in range(1, 10**6 + 1):
    s %= k
    if s == 0:
        print(i)
        exit()
    s = s*10 +7 i range(1, 10**6 + 1) range 1 10**6 + 1 10**6 10 6 1 s %= k s k if s == 0:
        print(i)
        exit()
     s == 0 s 0 print(i) print i exit() exit s = s*10 +7 s s*10 +7 s*10 s 10 7 print(-1) print -1 k = int(input()) int(input()) k s = s*10 +7 s*10 +7 s ans = 0 0 ans s %= k k s s = 7 7 s
k = int(input())
ans = 0
s = 7

for i in range(1, 10**6 + 1):
    s %= k
    if s == 0:
        print(i)
        exit()
    s = s*10 +7

print(-1) 