K = int(input())

ai_1 = 0
for i in range(K):
    ai = (10*ai_1 + 7)%K
    if ai==0:
        print(i+1)
        exit()
    ai_1 = ai

print("-1")
 K = int(input()) K int(input()) int input() input ai_1 = 0 ai_1 0 for i in range(K):
    ai = (10*ai_1 + 7)%K
    if ai==0:
        print(i+1)
        exit()
    ai_1 = ai i range(K) range K ai = (10*ai_1 + 7)%K ai (10*ai_1 + 7)%K 10*ai_1 + 7 10*ai_1 10 ai_1 7 K if ai==0:
        print(i+1)
        exit()
     ai==0 ai 0 print(i+1) print i+1 i 1 exit() exit ai_1 = ai ai_1 ai print("-1") print "-1" ai_1 = ai ai ai_1 ai_1 = 0 0 ai_1 K = int(input()) int(input()) K ai = (10*ai_1 + 7)%K (10*ai_1 + 7)%K ai
K = int(input())

ai_1 = 0
for i in range(K):
    ai = (10*ai_1 + 7)%K
    if ai==0:
        print(i+1)
        exit()
    ai_1 = ai

print("-1")

