K = int(input())
count =1

x = 7%K

for i in range(0,K+1):
    if x== 0:
        print(count)
        break

    count+=1
    x = (x*10+7)%K

if i== K:  
    print(-1) K = int(input()) K int(input()) int input() input count =1 count 1 x = 7%K x 7%K 7 K for i in range(0,K+1):
    if x== 0:
        print(count)
        break

    count+=1
    x = (x*10+7)%K i range(0,K+1) range 0 K+1 K 1 if x== 0:
        print(count)
        break

     x== 0 x 0 print(count) print count break count+=1 count 1 x = (x*10+7)%K x (x*10+7)%K x*10+7 x*10 x 10 7 K if i== K:  
    print(-1) i== K i K print(-1) print -1 count =1 1 count x = 7%K 7%K x x = (x*10+7)%K (x*10+7)%K x K = int(input()) int(input()) K count+=1 1 count
K = int(input())
count =1

x = 7%K

for i in range(0,K+1):
    if x== 0:
        print(count)
        break

    count+=1
    x = (x*10+7)%K

if i== K:  
    print(-1)