n,k=map(int,input().split())
l=[int(input()) for _ in range(n)]
r=[1]*n
for i in range(n):
  wk=l[i]
  for j in range(i+1,n):
    if abs(wk-l[j])<=k:
      r[j]=max(r[j],r[i]+1)
      break
print(max(r))