K = int(input())

k = 1
a = 7
for i in range(10**6+5):
    if a%K == 0:
        print(k)
        exit()
    a = (a*10 + 7) % K
    k += 1
    
print(-1) K = int(input()) K int(input()) int input() input k = 1 k 1 a = 7 a 7 for i in range(10**6+5):
    if a%K == 0:
        print(k)
        exit()
    a = (a*10 + 7) % K
    k += 1
     i range(10**6+5) range 10**6+5 10**6 10 6 5 if a%K == 0:
        print(k)
        exit()
     a%K == 0 a%K a K 0 print(k) print k exit() exit a = (a*10 + 7) % K a (a*10 + 7) % K a*10 + 7 a*10 a 10 7 K k += 1 k 1 print(-1) print -1 K = int(input()) int(input()) K a = 7 7 a a = (a*10 + 7) % K (a*10 + 7) % K a k = 1 1 k k += 1 1 k
K = int(input())

k = 1
a = 7
for i in range(10**6+5):
    if a%K == 0:
        print(k)
        exit()
    a = (a*10 + 7) % K
    k += 1
    
print(-1)