n,k=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=[0]*n

for i in range(n-2,-1,-1):
  for j in range(i,n-1):
    tmp=0
    for m in range(j+1,n):
      t = 1 if abs(l[j]-l[m])<=k else 0
      ans[j]=t+ans[m]
      if tmp<ans[j]:break
      tmp=ans[j]
print(ans[0]+1)