import java.util.*;

public class main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int dotNumber = sc.nextInt();
		int max = sc.nextInt();
		List<Integer> dot = new ArrayList<>();
		for (int i = 0; i < dotNumber; i++) {
			dot.add(sc.nextInt());
		}
		Collections.sort(dot);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < dotNumber; i++) {
			for (int j = i; j < dotNumber; j++) {
				if ((dot.get(j) - dot.get(i)) <= max) {
					int sum = dotNumber - (j-i+1);
					if (sum < min) {
						min = sum;
					}
				}
			}
		}
		System.out.println(""+min);
	}
}