if __name__ == '__main__':



	k = int(eval(input()))



	# mod K 問題



	s = set()

	x = 7 % k

	i = 1

	cnt = -1

	while x not in s:

		if x == 0:

			cnt = i

			break

		s.add(x)

		x = (10 * x + 7) % k

		i += 1



	print(cnt)

	
if __name__ == '__main__':



	k = int(eval(input()))

	x = 0

	for i in range(10**6):

		x = (10 * x + 7) % k

		if x == 0:

			print((i+1))

			exit()

	print((-1))

if __name__ == "__main__":
    k = int(eval(input()))
    # mod K 問題
    s = set()
    x = 7 % k
    i = 1
    cnt = -1
    while x not in s:
        if x == 0:
            cnt = i
            break
        s.add(x)
        x = (10 * x + 7) % k
        i += 1
    print(cnt)

if __name__ == "__main__":
    k = int(eval(input()))
    x = 0
    for i in range(10**6):
        x = (10 * x + 7) % k
        if x == 0:
            print((i + 1))
            exit()
    print((-1))

-    # mod K 問題 -    s = set() -    x = 7 % k -    i = 1 -    cnt = -1 -    while x not in s: +    x = 0 +    for i in range(10**6): +        x = (10 * x + 7) % k -            cnt = i -            break -        s.add(x) -        x = (10 * x + 7) % k -        i += 1 -    print(cnt) +            print((i + 1)) +            exit() +    print((-1))