import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
public class Contest{
    public static void main(String[] args) {
        MyScanner sc=new MyScanner();
        int n=sc.ni();
        int k=sc.ni();
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
          arr[i]=sc.ni();
        Arrays.sort(arr);
        int d=0,max=Integer.MIN_VALUE;
        for(int i=0;i<n-1;i++){
          for(int j=i+1;j<n;j++){
            if(arr[j]-arr[i]<=k && j!=n-1) continue;
            else if(arr[j]-arr[i]<=k && j==n-1){d=j-i+1;}
            else{d=j-i;break;}
          }
          // System.out.println("debug:"+arr[i]+" "+d);
          if(d>max) max=d;
        }
        // System.out.println(max);
        System.out.println((n-max));
    }


    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int ni() {
          return Integer.parseInt(next());
      }
      float nf() {
        return Float.parseFloat(next());
      }
      long nl() {
          return Long.parseLong(next());
      }

      double nd() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
    try {
       str = br.readLine();
    } catch (IOException e) {
       e.printStackTrace();
    }
    return str;
      }
   }
}