K=int(input())
m=0
count=1
chk=0
for i in range(K):
	m=(m*10+7)%K
	if m==0:
		print(count)
		chk=1
		break
	count+=1

if chk==0:
	print(-1) K=int(input()) K int(input()) int input() input m=0 m 0 count=1 count 1 chk=0 chk 0 for i in range(K):
	m=(m*10+7)%K
	if m==0:
		print(count)
		chk=1
		break
	count+=1 i range(K) range K m=(m*10+7)%K m (m*10+7)%K m*10+7 m*10 m 10 7 K if m==0:
		print(count)
		chk=1
		break
	 m==0 m 0 print(count) print count chk=1 chk 1 break count+=1 count 1 if chk==0:
	print(-1) chk==0 chk 0 print(-1) print -1 m=(m*10+7)%K (m*10+7)%K m m=0 0 m K=int(input()) int(input()) K chk=0 0 chk count=1 1 count chk=1 1 chk count+=1 1 count
K=int(input())
m=0
count=1
chk=0
for i in range(K):
	m=(m*10+7)%K
	if m==0:
		print(count)
		chk=1
		break
	count+=1

if chk==0:
	print(-1)