output_description: Print an integer representing the position of the first occurrence of a
  multiple of K. (For example, if the first occurrence is the fourth element of
  the sequence, print `4`.)
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      K
attempt: K = int(input())
  mod = K
  if K == 1:
      print(1)
  elif K % 2 == 0 or K % 5 == 0:
      print(-1)
  elif K % 7 != 0:
      x = 10 % mod
      X = [1] * K
      S = [1] * K
      for i in range(1, K + 1):
          X[i] = (X[i - 1] * x) % mod
          S[i] = S[i - 1] + X[i]
          if S[i] % mod == 0:
              print(i + 1)
              exit()
      print(-1)
  else:
      mod = K // 7
      if mod == 1:
          print(1)
      else:
          x = 10 % mod
          y = 1 % mod
          X = [y] * K
          S = [y] * K
          for i in range(1, K + 1):
              X[i] = (X[i - 1] * x) % mod
              S[i] = S[i - 1] + X[i]
              if S[i] % mod == 0:
                  print(i + 1)
                  exit()
      print(-1)
  
problem_description: Statement
  
  Takahashi loves the number 7 and multiples of K.
  
  Where is the first occurrence of a multiple of K in the sequence
  7,77,777,\ldots? (Also see Output and Sample Input/Output below.)
  
  If the sequence contains no multiples of K, print `-1` instead.
samples: [{"input": "101", "output": "4\n    \n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\n* * *"}, {"input": "2", "output": "-1\n    \n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\n* * *"}, {"input": "999983", "output": "999982"}]