import java.io.*;
import java.util.*;
public class CFC940A {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s[] = br.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int d = Integer.parseInt(s[1]);

        int[] nos = new int[n];

        s = br.readLine().split(" ");
        for(int i=0;i<n;i++){
            nos[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(nos);
        int distance = 0;
        int length, max_length = Integer.MIN_VALUE;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if((nos[j] - nos[i]) <= d){
                    length = j-i;
                    if(length > max_length){
                        max_length = length;
                    }
                }
            }
        }

        System.out.println(n - max_length - 1);
    }
}
