
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = []
result = 1
for j in range(N):
  B.append(1)
  for k in range(j):
    if A[N-j-1] <= A[N-k-1] and A[N-k-1] -  A[N-j-1] <= K:
      B[j] = max(B[j], B[k] + 1)
    elif A[N-k-1] < A[N-j-1] and A[N-j-1] - A[N-k-1] <= K:
      B[j] = max(B[j], B[k] + 1)
  if B[j] >= result:
    result = B[j]
print(result)