k = int(eval(input()))

count = 1

n = 0

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

    print((-1))

else:

  while 1:

      n = (n * 10 + 7) % k  

      if n == 0:

        break 

      count += 1

  print(count)
def main(h):

  count = 1

  n = 0

  for i in range (k):

    n = (n * 10 + 7) % k  

    if n == 0: 

      print(count)

      return 0

    count += 1

  print((-1))

  

if __name__ == '__main__':

  k = int(eval(input()))

  main(k)
k = int(eval(input()))
count = 1
n = 0
if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
    while 1:
        n = (n * 10 + 7) % k
        if n == 0:
            break
        count += 1
    print(count)

def main(h):
    count = 1
    n = 0
    for i in range(k):
        n = (n * 10 + 7) % k
        if n == 0:
            print(count)
            return 0
        count += 1
    print((-1))


if __name__ == "__main__":
    k = int(eval(input()))
    main(k)

-k = int(eval(input())) -count = 1 -n = 0 -if k % 2 == 0 or k % 5 == 0: -    print((-1)) -else: -    while 1: +def main(h): +    count = 1 +    n = 0 +    for i in range(k): -            break +            print(count) +            return 0 -    print(count) +    print((-1)) + + +if __name__ == "__main__": +    k = int(eval(input())) +    main(k)