n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
subs=[[] for i in range(n)]

idx=0
for ai in a:
  flg=True
  for i in range(idx+1):
    if len(subs[i])==0:
      if flg:
        subs[i].append(ai)
        idx+=1
      break
    else:
      if abs(subs[i][-1]-ai)<=k:
        subs[i].append(ai)
        flg=False

ans=0
for i in range(idx):
  #print(subs[i])
  ans=max(ans,len(subs[i]))
print(ans)