N,K=map(int,input().split())
A = []
for i in range(N):
  A.append(int(input()))
al = [1]*N
for i in range(N-2, -1, -1):
  for j in range(i+1, N):
    if abs(A[i]-A[j])<=K:
      al[i] += al[j]
      break
print(max(al))