lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
K = lines[0][1]

dp = []
for i in 1..N do
  low_last = 0
  high_last = 0
  num = lines[i][0]
  for j in 1..i-1 do
    if lines[i-j][0] < num and lines[i-j][0] + K >= num then
      low_last = dp[i-j-1]
      break
    end
  end
  for j in 1..i-1 do
    if lines[i-j][0] >= num and lines[i-j][0] <= num + K then
      high_last = dp[i-j-1]
      break
    end
  end
  if low_last < high_last then
    dp[i-1] = high_last + 1
  else
    dp[i-1] = low_last + 1
  end
end
    
dp_max = 0
for i in 1..N do
  if dp_max < dp[i-1] then
    dp_max = dp[i-1]
  end
end
puts dp_max