
import java.util.Arrays;
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int d = in.nextInt();
        int x[] = new int[n+1];
        for(int i=1;i<=n;i++){
            x[i] = in.nextInt();
        }
        Arrays.sort(x);
        int ans = Integer.MAX_VALUE;
        boolean valid = false;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                valid = true;
                for(int k=i;k<=j;k++){
                    //valid = true;
                    for(int l=k;l<=j;l++){
                        if(x[l]-x[k]>d){
                            valid = false;
                            break;
                        }
                    }
                    if(!valid){
                        break;
                    }
                }
                if(valid){
                    ans = Math.min(ans,i-1+n-j);
                }
            }
        }
        out.println(ans);
        out.flush();
    }

    public static void main(String[] args) {
        new Main().solve(0,new Scanner(System.in),new PrintWriter(System.out));
    }
}
