k = int(input())

if k%2 == 0 or k%5 == 0:
    print(-1)

else:
    ans = -1
    a = 7
    
    if k == 7 or k==1:
        print(1)
    
    else:
        for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
        print(ans) k = int(input()) k int(input()) int input() input if k%2 == 0 or k%5 == 0:
    print(-1)

else:
    ans = -1
    a = 7
    
    if k == 7 or k==1:
        print(1)
    
    else:
        for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
        print(ans) 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 ans = -1 ans -1 a = 7 a 7 if k == 7 or k==1:
        print(1)
    
    else:
        for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
        print(ans) k == 7 or k==1 k == 7 k 7 k==1 k 1 print(1) print 1 for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
         i range(2,10**7) range 2 10**7 10 7 a = (10*a + 7)%k a (10*a + 7)%k 10*a + 7 10*a 10 a 7 k if a==0:
                ans =i
                break
        
         a==0 a 0 ans =i ans i break print(ans) print ans a = 7 7 a k = int(input()) int(input()) k a = (10*a + 7)%k (10*a + 7)%k a ans =i i ans ans = -1 -1 ans
k = int(input())

if k%2 == 0 or k%5 == 0:
    print(-1)

else:
    ans = -1
    a = 7
    
    if k == 7 or k==1:
        print(1)
    
    else:
        for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
        print(ans)