import java.util.Scanner;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.Collections;
import java.util.ArrayList;

public class A940{

  public static boolean checkInRange(int number1, int number2 , int diameter){
    boolean check = false;
    int abs = number1 - number2;
    if (number1 - number2 < 0){
      abs = number2 - number1 ;
    }
    if (abs <=diameter){
      check = true;
    }
    return check;
  }

  public static void main(String[] args){


    Scanner inp = new Scanner(System.in);

    String inf = inp.nextLine();
    List<Integer> infs = Arrays.stream(inf.split(" ")).map(Integer::parseInt).collect(Collectors.toList());
    String numb = inp.nextLine();
    List<Integer> numbs = Arrays.stream(numb.split(" ")).map(Integer::parseInt).collect(Collectors.toList());

    Collections.sort(numbs);

    int n = infs.get(0);
    int diameter = infs.get(1);
    //System.out.println("Diameter " + diameter + " n " + n);

    List<Integer> value = new ArrayList<Integer>();


    //System.out.println(numbs);
    for (int i = 0 ; i < n ;i ++){
      int tmp = 0 ;
      for (int j = i+1 ; (j < n && checkInRange(numbs.get(i), numbs.get(j), diameter)) ; j++ ){
        //  System.out.println(tmp);
        tmp += 1;
      }
      value.add(tmp + 1);
    }
    //System.out.println(value);
    System.out.println(n - Collections.max(value));
  }
}
