K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

start = j = 7 % K
count = 1

#無限ループ
while True:
    #0の時
    if j == 0:
        print(count)
        exit()
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        exit() K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
    print(-1)
    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 exit() exit start = j = 7 % K start 7 % K 7 K = j = 7 % K j 7 % K count = 1 count 1 while True:
    #0の時
    if j == 0:
        print(count)
        exit()
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        exit() True if j == 0:
        print(count)
        exit()
        
     j == 0 j 0 print(count) print count exit() exit j = 10 * j + 7 j 10 * j + 7 10 * j 10 j 7 j = j % K j j % K j K count += 1 count 1 if j == start:
        print(-1)
        exit() j == start j start print(-1) print -1 exit() exit count += 1 1 count j = j % K j % K j count = 1 1 count K = int(input()) int(input()) K j = 7 % K 7 % K j start = j = 7 % K 7 % K start j = 10 * j + 7 10 * j + 7 j
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

start = j = 7 % K
count = 1

#無限ループ
while True:
    #0の時
    if j == 0:
        print(count)
        exit()
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        exit()