import sys
K=input()
if int(K)%2==0:
    print(-1)
    sys.exit()

S=int('7'*(len(K)))
ans=len(K)
K=int(K)
for i in range(10**6):
    if S%K==0:
        print(ans)
        break
    else:
        S=(S*10)%K+7
        ans+=1
else:
    print(-1) import sys sys K=input() K input() input if int(K)%2==0:
    print(-1)
    sys.exit() int(K)%2==0 int(K)%2 int(K) int K 2 0 print(-1) print -1 sys.exit() sys.exit sys exit S=int('7'*(len(K))) S int('7'*(len(K))) int '7'*(len(K)) '7' len(K) len K ans=len(K) ans len(K) len K K=int(K) K int(K) int K for i in range(10**6):
    if S%K==0:
        print(ans)
        break
    else:
        S=(S*10)%K+7
        ans+=1
else:
    print(-1) i range(10**6) range 10**6 10 6 if S%K==0:
        print(ans)
        break
    else:
        S=(S*10)%K+7
        ans+=1 S%K==0 S%K S K 0 print(ans) print ans break S=(S*10)%K+7 S (S*10)%K+7 (S*10)%K S*10 S 10 K 7 ans+=1 ans 1 print(-1) print -1 S=int('7'*(len(K))) int('7'*(len(K))) S S=(S*10)%K+7 (S*10)%K+7 S K=input() input() K K=int(K) int(K) K ans=len(K) len(K) ans ans+=1 1 ans
import sys
K=input()
if int(K)%2==0:
    print(-1)
    sys.exit()

S=int('7'*(len(K)))
ans=len(K)
K=int(K)
for i in range(10**6):
    if S%K==0:
        print(ans)
        break
    else:
        S=(S*10)%K+7
        ans+=1
else:
    print(-1)