import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
A = []
B = []
for i in range(N):
  A.append(int(input()))
  B.append(1)

for j in range(N):
  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[N-j-1] = max(B[N-j-1], B[N-k-1] + 1)
    elif A[N-k-1] < A[N-j-1] and A[N-j-1] - A[N-k-1] <= K:
      B[N-j-1] = max(B[N-j-1], B[N-k-1] + 1)
print(max(B))