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[] arr = new int[n];
    for (int i = 0; i<n; i++) arr[i] = in.nextInt();
    Arrays.sort(arr);
    int c = arr[n-1]-arr[0]; int k = 0; int i = 0; int j = n-1;
    boolean s =false;
    while(c>d){
      if((arr[i]-arr[i+1])<(arr[j]-arr[j-1])) {c = arr[j]-arr[i]; j--;}
      else {c = arr[j]-arr[i+1]; i++;} ++k; s=true;
    }
    if (s) {k--;}
    System.out.print(k);
  }
}
