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(input())
  main(k) 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)
   main count = 1 count 1 n = 0 n 0 for i in range (k):
    n = (n * 10 + 7) % k  
    if n == 0: 
      print(count)
      return 0
    count += 1
   i range (k) range k n = (n * 10 + 7) % k n (n * 10 + 7) % k n * 10 + 7 n * 10 n 10 7 k if n == 0: 
      print(count)
      return 0
     n == 0 n 0 print(count) print count return 0 0 count += 1 count 1 print(-1) print -1 h h if __name__ == '__main__':
  k = int(input())
  main(k) __name__ == '__main__' __name__ '__main__' k = int(input()) k int(input()) int input() input main(k) main k 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)
   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)
   main k = int(input()) int(input()) k
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(input())
  main(k)