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

cnt = 1
cnt_list = []
for i in range(N):
  F = A[i]
  for j in range(i+1,N):
    num = abs(A[j]-F)
    if num <= K:
      F = A[j]
      cnt +=1
    cnt_list.append(cnt)
  cnt = 1
    
print(max(cnt_list))