n,k = gets.split.map &:to_i
as = []

n.times{
	as << gets.to_i
}

arr = Array.new(n + 1).map{ Array.new }

arr[1] << 1

lens = {1 => true}

(2..n).each{ |i|
	flag = false

	(lens.size - 1).downto(0){ |j|
		len = lens.keys[j]
		arr[len].each{ |kk|
			if (as[kk-1] - as[i-1]).abs <= k then
				arr[len + 1] << i
				lens[len + 1] = true
				flag = true
				break
			end
		}
		
		if flag then
			break
		end
	}
	
	if ! flag then
		arr[1] << i
	end
}

print lens.keys[-1]