public class PointsOnTheLine {
    public static void main(String[] args) {
        java.util.Scanner s = new java.util.Scanner(System.in);
        int n = s.nextInt(), d = s.nextInt(), sum = 0, ms = 0;
        int[] D = new int[101];
        for (int i = 0; i < n; i++) D[s.nextInt() - 1]++;
        for (int i = 0; i < 100; i++) {
            sum = sum - D[Math.max(0,i - d - 1)] + D[i];
            ms = Math.max(sum, ms);
        }
        System.out.println(n - ms);
    }
}
