import sys

import math

import time

sys.setrecursionlimit(int(1e6))

if False:

    dprint = print

else:

    def dprint(*args):

        pass



k = list(map(int, input().split()))[0]



if (k % 7 == 0):

    l = 9*k/7

else:

    l = 9*k

dprint('k, l = ', k, l)



i = 1

n = 10

while(i < 10**6):

    m = n % l

    if (m == 1): # (10^i mod L = 1)

        print(i)

        exit()

    dprint('i, n, m = ', i, n, m)



    i = i + 1

    n = m * 10

else:

    print(-1)

import sys

import math

import time

sys.setrecursionlimit(int(1e6))

if False:

    dprint = print

else:

    def dprint(*args):

        pass



k = list(map(int, input().split()))[0]



am = 7 % k

i = 1



for i in range(k):

    if am==0:

        print(i+1)

        exit()

    else:

        i+=1

        am=(am*10+7)%k

 

print('-1')

import sys
import math
import time

sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:

    def dprint(*args):
        pass


k = list(map(int, input().split()))[0]
if k % 7 == 0:
    l = 9 * k / 7
else:
    l = 9 * k
dprint("k, l = ", k, l)
i = 1
n = 10
while i < 10**6:
    m = n % l
    if m == 1:  # (10^i mod L = 1)
        print(i)
        exit()
    dprint("i, n, m = ", i, n, m)
    i = i + 1
    n = m * 10
else:
    print(-1)

import sys
import math
import time

sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:

    def dprint(*args):
        pass


k = list(map(int, input().split()))[0]
am = 7 % k
i = 1
for i in range(k):
    if am == 0:
        print(i + 1)
        exit()
    else:
        i += 1
        am = (am * 10 + 7) % k
print("-1")

-if k % 7 == 0: -    l = 9 * k / 7 -else: -    l = 9 * k -dprint("k, l = ", k, l) +am = 7 % k -n = 10 -while i < 10**6: -    m = n % l -    if m == 1:  # (10^i mod L = 1) -        print(i) +for i in range(k): +    if am == 0: +        print(i + 1) -    dprint("i, n, m = ", i, n, m) -    i = i + 1 -    n = m * 10 -else: -    print(-1) +    else: +        i += 1 +        am = (am * 10 + 7) % k +print("-1")