import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static int[] count(List<Integer> x, int d) {
        int[] result = new int[x.size()];
        for (int i = 0; i < x.size(); i++) {
            for (int j = 0; j < x.size(); j++) {
                if (Math.abs(x.get(i) - x.get(j)) > d) {
                    result[i] += 1;
                    result[j] += 1;
                }
            }
        }
        return result;
    }

    private static boolean all(int[] a) {
        for (int anA : a) {
            if (anA != 0) return false;
        }
        return true;
    }

    private static int maxi(int[] a) {
        int max = 0;
        for (int i = 1; i < a.length; i++) {
            if (a[i] > a[max]) max = i;
        }
        return max;
    }

    public static void main(String[] args) {
        Reader r = new Reader(System.in);
        int n = r.nextInt(), d = r.nextInt();
        List<Integer> x = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            x.add(r.nextInt());
        }
        for (int i = 0;; i++) {
            int[] count = count(x, d);
            if (all(count)) {
                System.out.println(i);
                return;
            }
            x.remove(maxi(count));
        }
    }
}

class Reader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    Reader(InputStream is) {
        reader = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(nextLine());
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.valueOf(next());
    }
}

/*
4 1
1 51 52 99
>> 2
*/

/*
2 1
1 100
>> 1
 */