def resolve():
  N, K = map(int, input().split(" "))
  checked_count = 0
  link_from = [[] for i in range(N)]
  link_to = [None] * N
  depth = [0] * N
  A = [0] * N

  # 入力
  for i in range(N):
    A[i] = int(input())

  # 接続を作る
  for i in range(N - 1):
    if link_to[i] is not None:
      continue

    next_index_diff = 1
    while i + next_index_diff < N:
      if abs(A[i] - A[i + next_index_diff]) <= K:
        link_from[i + next_index_diff].append(i)
        link_to[i] = i + next_index_diff
        break
      next_index_diff += 1

  # 逆順で幅優先探索
  max_val = 0
  num_checked_count = 0
  next_nodes = [N-1]
  count = [0] * N

  for i in reversed(range(N)):
    if link_to[i] is None:
      next_nodes = [i]
      while len(next_nodes) != 0:
        next_nodes_temp = []
        for node in next_nodes:
          num_checked_count += 1
          if link_to[node] is None:
            count[node] = 1
          else:
            count[node] += count[link_to[node]] + 1

          if count[node] > max_val:
            max_val = count[node]
          next_nodes_temp.extend(link_from[node])

        next_nodes = next_nodes_temp
    if num_checked_count >= N:
      break
  print(max_val)

if __name__ == "__main__":
  resolve()