K = int(input())

seven = [0]*K
seven[0] = 7%K
for i in range(1,K):
    seven[i] = (10*seven[i-1]+7)%K


for i in range(K):
    if seven[i] == 0:
        print(i+1)
        exit()
print(-1) K = int(input()) K int(input()) int input() input seven = [0]*K seven [0]*K [0] 0 K seven[0] = 7%K seven[0] seven 0 7%K 7 K for i in range(1,K):
    seven[i] = (10*seven[i-1]+7)%K i range(1,K) range 1 K seven[i] = (10*seven[i-1]+7)%K seven[i] seven i (10*seven[i-1]+7)%K 10*seven[i-1]+7 10*seven[i-1] 10 seven[i-1] seven i-1 i 1 7 K for i in range(K):
    if seven[i] == 0:
        print(i+1)
        exit() i range(K) range K if seven[i] == 0:
        print(i+1)
        exit() seven[i] == 0 seven[i] seven i 0 print(i+1) print i+1 i 1 exit() exit print(-1) print -1 K = int(input()) int(input()) K seven = [0]*K [0]*K seven
K = int(input())

seven = [0]*K
seven[0] = 7%K
for i in range(1,K):
    seven[i] = (10*seven[i-1]+7)%K


for i in range(K):
    if seven[i] == 0:
        print(i+1)
        exit()
print(-1)