import java.util.*;

public class TaskA {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int d = input.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = input.nextInt();
        }
        Arrays.sort(a);
        int result = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(a[j] - a[i] <= d) {
                    result = Math.max(result, j - i + 1);
                }
            }
        }
        System.out.print(n - result);
    }
}