import java.io.*;
import java.util.*;

public class naloga1{
    static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    // static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws Exception{
        StringTokenizer st=new StringTokenizer(in.readLine());
        int n=Integer.parseInt(st.nextToken());
        int r=Integer.parseInt(st.nextToken());
        int[]q=new int[n];
        st=new StringTokenizer(in.readLine());
        for(int i=0;i<n;i++) {
            q[i]=Integer.parseInt(st.nextToken());
        }
        Arrays.sort(q);
        int dolzina=0;
        for(int i=0;i<n;i++) {
            for(int j=n-1;j>=0;j--) {
                if(q[j]-q[i]<=r) {
                    if(1+j-i>dolzina) {
                        dolzina=1+j-i;
                    }
                }
            }
        }
        int rez=n-dolzina;
        System.out.println(rez);
    }
}
