n,k=map(int,input().split())
oc=[int(input())]
cnt=[1]
for i in range(n-1):
  x=int(input())
  for j in range(len(oc)):
    fl=1
    if abs(oc[j]-x)<=k:
      fl=0
      oc[j]=x
      cnt[j]+=1
  if fl:
    oc.append(x)
    cnt.append(0)

print(max(cnt))