
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;


public class A {
    static final int MAXN = 0x3f3f3f3f;
    static int [] res = new int [105];
    static int [] num = new int [105];
    static int n, d, mmax, max1;
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) throws IOException {
        in.nextToken(); n = (int)in.nval;
        in.nextToken(); d = (int)in.nval;
        for(int i = 0; i < n; i++){
            in.nextToken();
            num[i] = (int) in.nval;
        }
        Arrays.sort(num, 0, n);
//        int a = solve(0, n - 1);
        int max = 1;
        for(int i = 0; i < n; i++){
            int max1 = 1;
            for(int j = i + 1; j < n; j++){
                if(num[j] - num[i] <= d){
                    max1++;
                }
                
                if(max1 > max){
                    max = max1;
                }
            }
        }
        out.println(n - max);
        out.flush();
    }
    
    private static int solve(int L, int R){
        int t = 0;
        if(num[R] - num[L] > d){ // 需要删点、、
            return t = Math.min(solve(L, R - 1) + 1, solve(L + 1, R) + 1);
        }else{
            return t;
        }
    }
    
}