import sys



K = int(eval(input()))



seven = 0

for i in range(K+2):

    seven += (7 * pow(10, i, K)) % K

    seven %= K    

    if seven == 0:

        print((i+1))

        sys.exit()



print((-1))
import sys



K = int(eval(input()))



seven = 7

seven %= K

for i in range(K+2):

    if seven == 0:

        print((i+1))

        sys.exit()

    seven = seven * 10 + 7

    seven %= K



print((-1))
import sys

K = int(eval(input()))
seven = 0
for i in range(K + 2):
    seven += (7 * pow(10, i, K)) % K
    seven %= K
    if seven == 0:
        print((i + 1))
        sys.exit()
print((-1))

import sys

K = int(eval(input()))
seven = 7
seven %= K
for i in range(K + 2):
    if seven == 0:
        print((i + 1))
        sys.exit()
    seven = seven * 10 + 7
    seven %= K
print((-1))

-seven = 0 +seven = 7 +seven %= K -    seven += (7 * pow(10, i, K)) % K -    seven %= K +    seven = seven * 10 + 7 +    seven %= K