N,K=map(int,input().split())
A=[int(input()) for _ in range(N)]
An=set(range(N))
ans=0
while len(An):
  AL=list(An)
  a=A[AL[0]]
  cnt=0
  rem=set()
  for i in An:
    if abs(A[i]-a)<=K:
      a=A[i]
      rem.add(i)
      cnt+=1
  An-=rem
  ans=max(ans,cnt)
print(ans)