import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class A {


    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int count =0;
        int l = 0;
        int r = n-1;
        while(l<=r){
            if(array[r] - array[l] <= d){
                break;
            }else{
                if(array[r-1] - array[l] <= array[r] - array[l+1]){
                    r = r-1;
                }else{
                    l=l+1;
                }
                count++;
            }
        }
        System.out.println(count);
    }


}