n = int(input().rstrip())

def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
    
calc(n) n = int(input().rstrip()) n int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
     calc result = 0 result 0 count = 0 count 0 if target % 2 == 0:
        print(-1)
        return
        
     target % 2 == 0 target % 2 target 2 0 print(-1) print -1 return for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
     i range(n) range n result = (result * 10 + 7) % target result (result * 10 + 7) % target result * 10 + 7 result * 10 result 10 7 target count += 1 count 1 if result == 0:
            print(count)
            return
    
     result == 0 result 0 print(count) print count return print(-1) print -1 target target calc(n) calc n def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
     def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
     calc n = int(input().rstrip()) int(input().rstrip()) n
n = int(input().rstrip())

def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
    
calc(n)