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