N, K = [int(i) for i in input().split()]
AS = [int(input()) for _ in range(N)]

ss = [[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([i])


print(max([len(ss[0])-1, *[len(s) for s in ss[1:]]]))
