K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1
N = 0
while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break
print(i) K = int(input()) K int(input()) int input() input i = 1 i 1 if K % 5 == 0 or K % 2 == 0:
    i = -1 K % 5 == 0 or K % 2 == 0 K % 5 == 0 K % 5 K 5 0 K % 2 == 0 K % 2 K 2 0 i = -1 i -1 N = 0 N 0 while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break True if i == -1:
        break
     i == -1 i -1 break N = (N * 10 + 7)  %K N (N * 10 + 7)  %K N * 10 + 7 N * 10 N 10 7 K if N % K != 0:
        i += 1
    else:
        break N % K != 0 N % K N K 0 i += 1 i 1 break print(i) print i N = 0 0 N i = -1 -1 i K = int(input()) int(input()) K i += 1 1 i N = (N * 10 + 7)  %K (N * 10 + 7)  %K N i = 1 1 i
K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1
N = 0
while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break
print(i)