

k = int(eval(input()))



if k % 2 == 0 or k % 5 == 0:

    print((-1))

else:

    n = 7

    cnt = 1

    for i in range(k):

        if n % k == 0:

            break

        cnt += 1

        n = (n * 10 + 7) % k

    print(cnt)

# -*- coding: utf-8 -*-

k = int(eval(input()))

ans = 0

n = 7



if k % 2 == 0 or k % 5 == 0:

    print((-1))

    exit(0)

c = 1

while True:

    if n % k == 0:

        break

    n = (n * 10 + 7) % k

    c += 1



print(c)

k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
    n = 7
    cnt = 1
    for i in range(k):
        if n % k == 0:
            break
        cnt += 1
        n = (n * 10 + 7) % k
    print(cnt)

# -*- coding: utf-8 -*-
k = int(eval(input()))
ans = 0
n = 7
if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit(0)
c = 1
while True:
    if n % k == 0:
        break
    n = (n * 10 + 7) % k
    c += 1
print(c)

+# -*- coding: utf-8 -*- +ans = 0 +n = 7 -else: -    n = 7 -    cnt = 1 -    for i in range(k): -        if n % k == 0: -            break -        cnt += 1 -        n = (n * 10 + 7) % k -    print(cnt) +    exit(0) +c = 1 +while True: +    if n % k == 0: +        break +    n = (n * 10 + 7) % k +    c += 1 +print(c)