var line = readline().split(' ');
	var n = Number(line[0]);
	var d = Number(line[1]);
	var numbers = readline().split(' ');
	numbers.sort(function(a, b) {
		return a-b;
	});

	var maxCount = n;
	for(var i=0; i<n; i++) {
		for(var j=i; j<n; j++){
			if (numbers[j] - numbers[i] <= d) {
				var count = n-(j-i+1);
				maxCount = Math.min(count, maxCount);
			}
		}
	}

	print(maxCount);