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[n];
             for(int i=0;i<n;i++)
             {
                 a[i]=nextInt();
             }
             Arrays.sort(a);
             int c=0;
             int i=n-1;
             int x=0;
             while(i>x)
             {
                 int d1=a[i]-a[x];
                 int d2=a[i]-a[x+1];
                 //bw.write("d1="+d1+" d2="+d2+"\n");
                 if(d2>d && d1>d)
                 {
                     c++;
                     i--;
                    // bw.write("c="+c+" i="+(i+1)+" a[i]="+a[i+1]+"\n");
                 }
                 else if(d1>d && d2<=d)
                 {
                     c++;
                     x++;
                     //bw.write("c="+c+" x="+x+" a[x]="+a[x]+"\n");
                 }
                 else if(d2<=d && d1<=d)
                 {
                     break;
                 }
             }
           // bw.write("i="+i+" x="+x+"\n");
             bw.write(c+"\n");
                 bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
    



