from collections import deque
N, K = [int(i) for i in input().split()]
AS = [int(input()) for _ in range(N)]
 
ss = deque([deque([0])])
 
for i in range(N):
  a = AS[i]
  f = False
  for s in ss:
    p = AS[s[-1]]
    if abs(a - p) <= K:
      s.append(i)
    else:
      f = True
 
  if f:
    ss.append(deque([i]))
 
 
f0 = ss.popleft()
print(max([len(f0)-1, *[len(s) for s in ss]]))
