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

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        StringTokenizer st1 = new StringTokenizer(br.readLine());
        int n = new Integer(st.nextToken());
        int d = new Integer(st.nextToken());
        br.close();
        int[] array = new int[n];
        int max = 0;
        for(int i=0;i<n;i++){
            array[i]=new Integer(st1.nextToken());
        }
        Arrays.sort(array);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int x = Math.abs(array[j]-array[i]);
                if(x<=d){
                    if(Math.abs(j-i)>max){
                        max = Math.abs(j-i);
                        //System.out.println(i+" "+j);
                    }
                }
            }
        }
        System.out.println(n-max-1);
    }
}