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