n,k = map(int,input().split())
a = [int(input()) for _ in range(n)]
s = set()
ans = 0
for i in range(n):
  cnt = 1
  tmp = a[i]
  for j in range(i+1,n):
    if j in s:
      break
    if abs(a[j]-tmp)<=k:
      cnt += 1
      tmp = a[j]
      s.add(j)
  ans = max(ans,cnt)
print(ans)