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

public class test {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		StringTokenizer st = new StringTokenizer(s.nextLine());
		int n = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		StringTokenizer st2 = new StringTokenizer(s.nextLine());
		int[] integers = new int[105];
		int smallest = 999;
		int largest = 0;
		for (int i = 0; i < n; i++) {
			int number = Integer.parseInt(st2.nextToken());
			if (number < smallest) {
				smallest = number;
			}
			if (number > largest) {
				largest = number;
			}
			integers[number]++;
		}
		if (largest - smallest <= d) {
			System.out.println("0");
			s.close();
			return;
		} else {
			int cand1 = 0;
			int cand2 = 0;
			for (int i = smallest + d + 1; i < 105; i++) {
				cand1 += integers[i];
			}
			for (int i = largest - d - 1; i >= 0; i--) {
				cand2 += integers[i];
			}
			System.out.println(Math.min(cand1, cand2));
		}
		s.close();
	}
}