import java.util.Arrays;
import java.util.Scanner;

public class PointsOnLine {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int d = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        System.out.println(solve(d, arr));
    }

    public static int solve(int d, int[] arr) {
        Arrays.sort(arr);
        int n = arr.length;
        int toRemove = 0;
        int p = 0;
        int q = n-1;
        int dia = arr[q]-arr[p];
        while (dia > d && p<q) {
            if (arr[p+1] - arr[p] > arr[q] - arr[q-1]) {
                p++;
            } else {
                q--;
            }
            dia = arr[q]-arr[p];
            toRemove++;
        }
        return toRemove;
    }
}