import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class A940 {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);

		int n, d;
		n = scanner.nextInt();
		d = scanner.nextInt();
		SortedSet<Integer> set = new TreeSet<Integer>();

		for (int i = 0; i < n; i++) {
			set.add(scanner.nextInt());
		}
		scanner.close();

		Integer[] points = new Integer[set.size()];
		set.toArray(points);

		for (int i = points.length; i >= 2; i--) {
			for (int j = 0; j < points.length-i+1; j++) {
				if (points[j+i-1]-points[j]<=d) {
					System.out.println(points.length-i);
					return;
				}
			}
		}
		System.out.println(0);
	}
}