import java.util.*;
import java.io.*;

public class A940 {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) throws Exception {

		st = new StringTokenizer(in.readLine());
		int n = i(), lim = i();

		int[] arr = new int[n];

		st = new StringTokenizer(in.readLine());
		for (int i = 0; i < n; i++) {
			arr[i] = i();
		}

		Arrays.sort(arr);

		int maxsize = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (arr[j] - arr[i] <= lim) {
					maxsize = Math.max(maxsize, j - i + 1);
				}
			}
		}

		out.println(Math.min(n - 1, n - maxsize));

		out.close();
	}

	static {
		try {
			in = new BufferedReader(new FileReader("cf.in"));
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
		}
	}
	static int i() {return Integer.parseInt(st.nextToken());}
	static double d() {return Double.parseDouble(st.nextToken());}
	static String s() {return st.nextToken();}
	static long l() {return Long.parseLong(st.nextToken());}
}
