var input = readline().split(' ').map(x => parseInt(x));
var diameter = input[1];
var points = readline().split(' ').map(x => parseInt(x));

function sortNumber(a,b) {
    return a - b;
}

var result = Infinity;
points.sort(sortNumber);

for (var i = 0; i < points.length; i++) {
  for (var j = points.length - 1; j > i; j--) {
    if (points[j] - points[i] <= diameter && i + (points.length - 1 - j) < result) {
      result = i + (points.length - 1 - j);
    }
  }
}

if (input[0] === 1) {
  result = 0;
}

print(result);

