import java.util.*;
import java.util.ArrayList;
public class Pointss{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int d = in.nextInt();
    int[] array = new int[n];
    for (int i = 0; i<n; i++) array[i] = in.nextInt();
    Arrays.sort(array);
    int i = 0;
			int j = 1;
			int count = 1;

			while(j < array.length) {
				if(array[j] - array[i] <= d) {
					count++;
					++j;
				} else {
					i++;
					++j;
				}
			}
    System.out.print(array.length - count);
  }
}
