import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n, d, i, j, x, ans = 0;
        int[] a = new int[101];
        n = in.nextInt();
        d = in.nextInt();
        for (i = 1; i <= n; i++) {
            x = in.nextInt();
            a[x]++;
        }
        for (i = 1; i <= 100; i++) {
            if (a[i] != 0) {
                int k = 0;
                for (j = Math.max(1, i-d);j <= i; j++)
                    k += a[j];
                ans = Math.max(ans, k);
            }
        }
        System.out.println(n - ans);
        in.close();
    }
}
		  		 					     	    	   	  	