import sys
K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    sys.exit()
i=1
K=9*K
ans=10-K

while(1):
    if 7*(ans-1)%K==0:
        print(i)
        sys.exit()
    i+=1
    ans=ans*10%K import sys sys K=int(input()) K int(input()) int input() input if K%2==0 or K%5==0:
    print('-1')
    sys.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' sys.exit() sys.exit sys exit i=1 i 1 K=9*K K 9*K 9 K ans=10-K ans 10-K 10 K while(1):
    if 7*(ans-1)%K==0:
        print(i)
        sys.exit()
    i+=1
    ans=ans*10%K 1 if 7*(ans-1)%K==0:
        print(i)
        sys.exit()
     7*(ans-1)%K==0 7*(ans-1)%K 7*(ans-1) 7 ans-1 ans 1 K 0 print(i) print i sys.exit() sys.exit sys exit i+=1 i 1 ans=ans*10%K ans ans*10%K ans*10 ans 10 K i=1 1 i K=9*K 9*K K i+=1 1 i ans=10-K 10-K ans K=int(input()) int(input()) K ans=ans*10%K ans*10%K ans
import sys
K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    sys.exit()
i=1
K=9*K
ans=10-K

while(1):
    if 7*(ans-1)%K==0:
        print(i)
        sys.exit()
    i+=1
    ans=ans*10%K