import java.io.*;
import java.util.*;
public class q1
{
  public static void main(String args[])throws IOException
  {
    Scanner in=new Scanner(System.in);
    PrintWriter pw=new PrintWriter(System.out, true);
    int n,d;
    n=in.nextInt();
    d=in.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    arr[i]=in.nextInt();
    Arrays.sort(arr);
    int i=0,j=0;int window=-1;
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<n;j++)
      {
        int win=arr[j]-arr[i];
      //  System.out.println(win+"\t"+window);
        if(win<=d)
        {
          if(j-i+1>window)
          window=j-i+1;
        }
      }
    }
    System.out.println(n-window);
  }
}
