class ST
	def initialize n
		@l = (1<<(n-1).bit_length)-1
		@h = [0]*(@l+@l+1)
	end
 
	def max
		return @h[0]
	end
 
	def [] l,r
		return if r < l
		l,r = @l+l+1,@l+r+1
		lx,rx = @h[l-1],@h[r-1]
		while l <= r
			lx = @h[l-1] if lx < @h[l-1]
			rx = @h[r-1] if rx < @h[r-1]
			l = (l+1)/2
			r = (r-1)/2
		end
		return lx < rx ? rx : lx
	end
 
	def []= i,v
		j = @l+i+1
		@h[j-1] = v
		@h[j-1] = v while 0 < (j/=2) && @h[j-1] < v
		return v
	end
end

N,K = gets.split.map(&:to_i)
max = ST.new N
N.times{
	a = gets.to_i
	max[a] = 1+max[[a-K,0].max,[N-1,a+K].min]
}
p max.max
