import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1) import sys sys k = int(input()) k int(input()) int input() input a = 0 a 0 for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit() i range(1, k+1) range 1 k+1 k 1 a = (a*10+7)%k a (a*10+7)%k a*10+7 a*10 a 10 7 k if a == 0:
		print(i)
		sys.exit() a == 0 a 0 print(i) print i sys.exit() sys.exit sys exit print(-1) print -1 k = int(input()) int(input()) k a = 0 0 a a = (a*10+7)%k (a*10+7)%k a
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)