
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class ArrangeMent {

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
    int d = Integer.parseInt(st.nextToken());
    int[] arr = new int[n];
    st = new StringTokenizer(br.readLine());
    for(int i = 0; i < n; i++) {
      arr[i] =  Integer.parseInt(st.nextToken());
    }
    Arrays.sort(arr);
    PrintWriter out = new PrintWriter(System.out);
    int best = 1;
    for(int len = n; len > 1; len--) {
      boolean found = false;
      for(int i = 0; i + len <= n; i++) {
        if(arr[i+len-1]-arr[i]<=d) {
          found = true;
          break;
        }
      }
      if(found) {
        best = len;
        break;
      }
    }
    out.println(n-best);
    out.close();
  }

}
