import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class A {

    private static int [][]s;

    public static int removeExtra(int []a, int l, int r, int d){
        if (l > r)
            return 0;
        if (a[r] - a[l] <= d)
            return 0;
        int k = (s[l][r-1]==-1)?removeExtra(a, l, r-1, d):s[l][r-1], m = (s[l+1][r]==-1)?removeExtra(a, l+1, r, d):s[l+1][r];
        s[l][r-1] = k;
        s[l+1][r] = m;
        return Math.min(k, m)+1;
    }

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt(), d = cin.nextInt();
        int []a = new int[N];
        s = new int[N][N];
        for (int i=0;i<N;++i)
            Arrays.fill(s[i], -1);
        for (int i=0;i<N;++i)
            a[i] = cin.nextInt();
        Arrays.sort(a);
        System.out.println(removeExtra(a, 0, N-1, d));
    }
}
