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