import java.util.*;
import java.io.*;
public class Points
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
    static StringTokenizer st=null;
    static String next()
    {
        while(st==null || !st.hasMoreElements())
        {
            try{
                st=new StringTokenizer(br.readLine());
            } catch (IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    static int nextInt()
    {
        return java.lang.Integer.parseInt(next());
    }
    static long nextLong()
    {
        return Long.parseLong(next());
    }
    
    static double nextDouble(){
        return Double.parseDouble(next());
    }
    public static void main(String[] args) {
        try{ 
             int n=nextInt();
             int d=nextInt();
             int a[];
             a=new int[1000];
             for(int i=0;i<n;i++)
             {
                 int x=nextInt();
                 a[x]++;
             }
             int max=0;
             for(int i=0;i<=105;i++)
             {
                 int s=0;
                // bw.write("*");
                 for(int j=i;j<=(i+d);j++)
                 {
                     s+=a[j];
                 }
                 max=Math.max(max,s);
             }
             bw.write((n-max)+"\n");
                 bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
    



