N,K=map(int,input().split())

alist=[]
for _ in range(N):
  a=int(input())
  alist.append(a)
#print(alist)

now=alist[0]
seq_list=[0]
for i in range(1,N):
  if abs(alist[i]-now)<=K:
    now=alist[i]
    seq_list.append(i)
#print(seq_list)
#print(len(seq_list))

index1=seq_list[1]
answer=len(seq_list)

for j in range(1,index1):
  now=alist[j]
  seq_list=[j]
  for i in range(j+1,N):
    if abs(alist[i]-now)<=K:
      now=alist[i]
      seq_list.append(i)
      
  if answer<len(seq_list):
    answer=len(seq_list)
    
print(answer)