N,K=map(int,input().split())
A=[int(input()) for _ in range(N)]
ng=[0]
for i in range(1,N):
  if abs(A[i]-A[i-1])>K:
    ng.append(i)
ng.sort()
ans=0
for i in ng:
  cnt=1
  a=A[i]
  for j in range(i+1,N):
    if abs(A[j]-a)<=K:
      cnt+=1
      a=A[j]
  ans=max(ans,cnt)
print(ans)