
K=int(input())
a_i=7%K
i=1
if a_i==0:
	exit(print(1))
while True:
	i+=1
	a_i=(10*a_i+7)%K
	if a_i==0:
		print(i)
		exit()
	if i>=K:
		print(-1)
		exit()

 K=int(input()) K int(input()) int input() input a_i=7%K a_i 7%K 7 K i=1 i 1 if a_i==0:
	exit(print(1)) a_i==0 a_i 0 exit(print(1)) exit print(1) print 1 while True:
	i+=1
	a_i=(10*a_i+7)%K
	if a_i==0:
		print(i)
		exit()
	if i>=K:
		print(-1)
		exit() True i+=1 i 1 a_i=(10*a_i+7)%K a_i (10*a_i+7)%K 10*a_i+7 10*a_i 10 a_i 7 K if a_i==0:
		print(i)
		exit()
	 a_i==0 a_i 0 print(i) print i exit() exit if i>=K:
		print(-1)
		exit() i>=K i K print(-1) print -1 exit() exit i=1 1 i K=int(input()) int(input()) K a_i=(10*a_i+7)%K (10*a_i+7)%K a_i a_i=7%K 7%K a_i i+=1 1 i

K=int(input())
a_i=7%K
i=1
if a_i==0:
	exit(print(1))
while True:
	i+=1
	a_i=(10*a_i+7)%K
	if a_i==0:
		print(i)
		exit()
	if i>=K:
		print(-1)
		exit()


