K = int(eval(input()))



a = 7

flag = False



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

  b = a%K

  if b==0:

    flag = True

    break

  a = b*10 + 7

if flag:

  print(i)

else:

  print((-1))
# 解答

K = int(eval(input()))

A = 7 % K 



flag = False

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

  if A == 0:

    flag = True

    break

  A = (A*10 + 7) % K



if flag:

  print(i)

else:

  print((-1))
K = int(eval(input()))
a = 7
flag = False
for i in range(1, K + 1):
    b = a % K
    if b == 0:
        flag = True
        break
    a = b * 10 + 7
if flag:
    print(i)
else:
    print((-1))

# 解答
K = int(eval(input()))
A = 7 % K
flag = False
for i in range(1, K + 1):
    if A == 0:
        flag = True
        break
    A = (A * 10 + 7) % K
if flag:
    print(i)
else:
    print((-1))

+# 解答 -a = 7 +A = 7 % K -    b = a % K -    if b == 0: +    if A == 0: -    a = b * 10 + 7 +    A = (A * 10 + 7) % K