output_description: Print the earliest possible time for the kangaroo to reach coordinate X.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      X
attempt: import sys
  
  input = sys.stdin.readline
  
  N, K = map(int, input().split())
  a = list(map(int, input().split()))
  S, f = [set() for i in range(N + 1)], [[0] * K for i in range(N + 1)]
  S[0].add(0)
  f[N][0] = 1
  for i, (al, ar) in enumerate(zip(a, a[::-1]), 1):
      for j in S[i - 1]:
          S[i].add(j)
          x = al + j
          if x < K:
              S[i].add(x)
      for j in range(K):
          if f[-i][j]:
              f[-i - 1][j] = 1
              if ar + j < K:
                  f[-i - 1][ar + j] = 1
  for i in range(N):
      for j in range(1, K):
          f[i][j] += f[i][j - 1]
  cnt = 0
  for i, x in enumerate(a):
      if x >= K:
          cnt += 1
          continue
      for j in S[i]:
          if K - x - j - 1 < 0 or f[i + 1][K - j - 1] - f[i + 1][K - x - j - 1] > 0:
              cnt += 1
              break
  print(N - cnt)
  
problem_description: Statement
  
  There is a kangaroo at coordinate 0 on an infinite number line that runs from
  left to right, at time 0. During the period between time i-1 and time i, the
  kangaroo can either stay at his position, or perform a jump of length exactly
  i to the left or to the right. That is, if his coordinate at time i-1 is x, he
  can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at
  coordinate X, and he wants to travel to coordinate X as fast as possible. Find
  the earliest possible time to reach coordinate X.
samples: [{"input": "6", "output": "3\n    \n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times,\nwhich is the earliest possible time.\n\n* * *"}, {"input": "2", "output": "2\n    \n\nHe can reach his nest at time 2 by staying at his position during the first\nsecond, and jumping to the right at the next second.\n\n* * *"}, {"input": "11", "output": "5"}]