N, K = gets.split.map(&:to_i)
ary = []
N.times do 
    ary << gets.to_i
end
max_cnt = 1
hash = {}
hash[N-1] = 1
(N-2).downto(0) do |n|
    hash[n] = 1
    n.upto(N-2) do |m|
        if (ary[n] - ary[m+1]).abs <= K
            hash[n] = hash[m+1] + 1
            break
        end
    end
    max_cnt = [max_cnt, hash[n]].max
end
puts max_cnt