k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
count=0
a=0
while True:
    a=(a*10+7)%k
    count+=1
    if a==0:
        print(count)
        exit() k=int(input()) k int(input()) int input() input if k%2==0 or k%5==0:
    print(-1)
    exit() k%2==0 or k%5==0 k%2==0 k%2 k 2 0 k%5==0 k%5 k 5 0 print(-1) print -1 exit() exit count=0 count 0 a=0 a 0 while True:
    a=(a*10+7)%k
    count+=1
    if a==0:
        print(count)
        exit() True a=(a*10+7)%k a (a*10+7)%k a*10+7 a*10 a 10 7 k count+=1 count 1 if a==0:
        print(count)
        exit() a==0 a 0 print(count) print count exit() exit count+=1 1 count a=(a*10+7)%k (a*10+7)%k a count=0 0 count a=0 0 a k=int(input()) int(input()) k
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
count=0
a=0
while True:
    a=(a*10+7)%k
    count+=1
    if a==0:
        print(count)
        exit()