K = int(eval(input()))



if K % 7 == 0:

    K //= 7



L = 9 * K



ans = -1



r = 10



for i in range(L):

    r %= L

    if r == 1:

        ans = i + 1

        break

    else:

        r = 10 * r



print(ans)
def main():

    K = int(eval(input()))

 

    work = 7

 

    answer = -1

    for i in range(1, K+1):

        i_mod = work % K

        if i_mod == 0 :

            answer = i

            break

        work = i_mod * 10 + 7

    print(answer)

main()
K = int(eval(input()))
if K % 7 == 0:
    K //= 7
L = 9 * K
ans = -1
r = 10
for i in range(L):
    r %= L
    if r == 1:
        ans = i + 1
        break
    else:
        r = 10 * r
print(ans)

def main():
    K = int(eval(input()))
    work = 7
    answer = -1
    for i in range(1, K + 1):
        i_mod = work % K
        if i_mod == 0:
            answer = i
            break
        work = i_mod * 10 + 7
    print(answer)


main()

-K = int(eval(input())) -if K % 7 == 0: -    K //= 7 -L = 9 * K -ans = -1 -r = 10 -for i in range(L): -    r %= L -    if r == 1: -        ans = i + 1 -        break -    else: -        r = 10 * r -print(ans) +def main(): +    K = int(eval(input())) +    work = 7 +    answer = -1 +    for i in range(1, K + 1): +        i_mod = work % K +        if i_mod == 0: +            answer = i +            break +        work = i_mod * 10 + 7 +    print(answer) + + +main()