import java.util.*;

public class A{
    
    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 res = 0; int count = 0;
        
        for (int i = 0; i < n; i++) {
            count =0;
            for (int j = i; j < n; j++) {
                if(points[j] - points[i] > d)
                {
                    break;
                }
                count++;
            }
            res = Math.max(res,count);
        }

        System.out.println(n - res);
        in.close();
    }
}