n,k=gets.split.map(&:to_i)
a=n.times.map{gets.to_i}
l = Array.new(n){0}
l[0] = 1
s = 1
(1...n).each do |i|
  (1..s).each do |j|
    break if i-j<0
    if (a[i-j] - a[i]).abs <= k
      l[i] = [l[i-j] + 1,l[i]].max
      s = 1
    else
      s += 1
    end
  end
end

p l[n-1]