K = int(input())

n = 7
for i in range(K):
	if n % K == 0: 
		print(i + 1)
		exit(0)
	n = (10 * n + 7) % K
    
print('-1') K = int(input()) K int(input()) int input() input n = 7 n 7 for i in range(K):
	if n % K == 0: 
		print(i + 1)
		exit(0)
	n = (10 * n + 7) % K
     i range(K) range K if n % K == 0: 
		print(i + 1)
		exit(0)
	 n % K == 0 n % K n K 0 print(i + 1) print i + 1 i 1 exit(0) exit 0 n = (10 * n + 7) % K n (10 * n + 7) % K 10 * n + 7 10 * n 10 n 7 K print('-1') print '-1' K = int(input()) int(input()) K n = 7 7 n n = (10 * n + 7) % K (10 * n + 7) % K n
K = int(input())

n = 7
for i in range(K):
	if n % K == 0: 
		print(i + 1)
		exit(0)
	n = (10 * n + 7) % K
    
print('-1')