/**
 * Created by Kratos-Pavilion on 04-03-2018.
 *
 * @author Kratos-Pavilion
 * @Date 04-03-2018
 */
import java.util.Scanner;
import java.util.Arrays;

public class Subset {
    public static void main(String[] args) throws Exception {

        Scanner d = new Scanner(System.in);
        int n = d.nextInt();
        int dia = d.nextInt();
        int c = 0, count = 0;
        int arr[] = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = d.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if ((arr[j] - arr[i]) <= dia)
                    c++;
            }
            count = Math.max(count, c);
            c = 0;
        }


        System.out.println(n-count);

    }
}
