
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d  = scanner.nextInt();

        int array[] = new int[101];

        int sums[] = new int[101];

        for (int i = 1; i <= n; i++) {
            int num = scanner.nextInt();
            array[num]++;
        }
        for (int i = 1; i <= 100; i++) {
            sums[i] = sums[i - 1] + array[i];
        }
        int min = Integer.MAX_VALUE;

        for (int i = 1; i <= 100 - d; i++) {
            min = Math.min(n - (sums[d + i] - sums[i - 1]), min);
        }


        System.out.println(min);

    }
}

