import java.util.Scanner;

public class A940 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int D = in.nextInt();
        int[] stat = new int[101];
        for (int n=0; n<N; n++) {
            stat[in.nextInt()]++;
        }
        int max = 0;
        for (int from=0; from<=100; from++) {
            int count = 0;
            int to = Math.min(100,from+D);
            for (int i=from; i<=to; i++) {
                count += stat[i];
            }
            max = Math.max(count, max);
        }
        System.out.println(N-max);
    }

}
