import java.util.*;

public class points {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[] x = new int[n];
		
		for (int i=0; i<n; i++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		
		int i = 0;
		int j = n-1;
		
		int minRemove = 0;
		while (x[j]-x[i]>d) {
			minRemove++;
			if (x[i+1]-x[i] > x[j] - x[j-1]) i++;
			else j--;
		}
		
		System.out.println(minRemove);
	}
}
