import java.util.ArrayList;
import java.util.Collections;
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>();
		Integer[] points=new Integer[n];
		ArrayList<Integer>pom=new ArrayList<>();
		for (int i = 0; i < n; i++) {
			pom.add(scanner.nextInt());
//			set.add(scanner.nextInt());
		}
		scanner.close();
		Collections.sort(pom);
		pom.toArray(points);
//		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(points.length-1);
	}
}