import java.io.*;
import java.math.BigDecimal;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int d = in.nextInt()+1;

        int[] count = new int[101];
        for (int i = 0; i < n; i++) {
            count[in.nextInt()]++;
        }

        int max = Integer.MIN_VALUE;
        int sum = 0;
        for (int i = 0; i < d; i++) {
            sum += count[i];
        }
        max = sum;
        for (int i = d; i <= 100; i++) {
            sum -= count[i-d];
            sum += count[i];
            max = Math.max(max, sum);
        }

        System.out.println(n-max);





//        while (in.hasNext()) {
//
//        }
    }

}