import java.util.*;
public class Main {
    static int[] in;
    static int n, out, minD;
	public static void main (String[] args){
	    Scanner sc = new Scanner(System.in);
	    n = sc.nextInt();
	    minD = sc.nextInt();
	    int maxSize = 0;
	    in = new int[n];
	    for(int i = 0; i < n; i++) in[i] = sc.nextInt();
	    Arrays.sort(in);
	    for(int i = 0; i < n; i++){
	        for(int j = n - 1; j >= i; j--){
	            if(in[j] - in[i] <= minD){
	                maxSize = Math.max(maxSize, j - i + 1);
	            }
	        }
	    }
	    System.out.println(n - maxSize);
	}
}