import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
public class Main 
{ 
    public static void main(String[] args) throws IOException 
    { 
  
        Scanner input = new Scanner(System.in);
        
        while(input.hasNext()){
            int[] l=new int[input.nextInt()];
            int ind=0;
            int d=input.nextInt();
            while(ind<l.length){
                l[ind]=input.nextInt();
                ind++;
            }
            System.out.println(s(l,d));
        }
        }
 
    public static int s(int[] l, int d){ 
        Arrays.sort(l);
        int i=0;
        int j=l.length-1;
        int ct=0;
        while(i<j){
            if(l[j]-l[i]<=d){
                return ct;
            }
            if(l[i+1]-l[i]>=l[j]-l[j-1]){
                i++;
                ct++;
                continue;
            }
            ct++;
            j--;
        }
        return ct;
    }
 
} 