
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.MIN_VALUE;
import static java.lang.Integer.parseInt;

public class A_Points_on_the_line {
    static int ar [] ;
    static int n,d;
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine());
        n = parseInt(tk.nextToken());
        d = parseInt(tk.nextToken());
        ar = new int[n];
        tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; i++) {
            ar[i] = parseInt(tk.nextToken());
        }
        Arrays.sort(ar);
        System.out.println(solve());
    }

    static int solve(){
        int max = MIN_VALUE;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; ++j) {
               if(ar[j] - ar[i] <= d){
                    int sz = j - i + 1;
                    if(sz > max)
                        max = sz;
               }
            }
        }
        return n - max;
    }
}
