
//package com.company;
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int[] points = new int[n];

        for (int i = 0; i < n; i++)
            points[i] = in.nextInt();

        Arrays.sort(points);

        int left = 0;
        int right = n - 1;

        for (int remove = 0; remove < n; remove++) {

            for (int leftRemove = 0; leftRemove <= remove; leftRemove++) {
                int rightRemove = remove - leftRemove;
                int newLeft = left + leftRemove;
                int newRight = right - rightRemove;

                if (points[newRight] - points[newLeft] <= d) {
                    System.out.println(remove);
                    return;
                }
            }
        }
    }
}
