import sys

k = int(input())

ans = [0]*(k+1)
ans[0] = 7 % k

if ans[0] == 0:
    print(1)
    
else:
    for i in range(k):
        ans[i+1] = (ans[i]*10 + 7) % k
        
        if ans[i+1] == 0:
            print(i+2)
            sys.exit()
            
    print(-1) import sys sys k = int(input()) k int(input()) int input() input ans = [0]*(k+1) ans [0]*(k+1) [0] 0 k+1 k 1 ans[0] = 7 % k ans[0] ans 0 7 % k 7 k if ans[0] == 0:
    print(1)
    
else:
    for i in range(k):
        ans[i+1] = (ans[i]*10 + 7) % k
        
        if ans[i+1] == 0:
            print(i+2)
            sys.exit()
            
    print(-1) ans[0] == 0 ans[0] ans 0 0 print(1) print 1 for i in range(k):
        ans[i+1] = (ans[i]*10 + 7) % k
        
        if ans[i+1] == 0:
            print(i+2)
            sys.exit()
            
     i range(k) range k ans[i+1] = (ans[i]*10 + 7) % k ans[i+1] ans i+1 i 1 (ans[i]*10 + 7) % k ans[i]*10 + 7 ans[i]*10 ans[i] ans i 10 7 k if ans[i+1] == 0:
            print(i+2)
            sys.exit()
            
     ans[i+1] == 0 ans[i+1] ans i+1 i 1 0 print(i+2) print i+2 i 2 sys.exit() sys.exit sys exit print(-1) print -1 k = int(input()) int(input()) k ans = [0]*(k+1) [0]*(k+1) ans
import sys

k = int(input())

ans = [0]*(k+1)
ans[0] = 7 % k

if ans[0] == 0:
    print(1)
    
else:
    for i in range(k):
        ans[i+1] = (ans[i]*10 + 7) % k
        
        if ans[i+1] == 0:
            print(i+2)
            sys.exit()
            
    print(-1)