N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
ans = 1
nums = [l[0]]
cnts = [1]
for i in range(1, N):
  flag = True
  for j in range(len(nums)):
    if abs(l[i]-nums[j]) <= K:
      nums[j] = l[i]
      cnts[j] += 1
      flag = False
  if flag:
    nums.append(l[i])
    cnts.append(1)
print(max(cnts))