import java.io.*;
import java.util.Arrays;
public class prog12
{
    public static void main(String args[]) throws IOException
    {BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        int n,d;
        String str1= br.readLine();
        n= Integer.parseInt(str1.substring(0, str1.indexOf(" ")));
        d= Integer.parseInt(str1.substring(str1.indexOf(" ")+1));
        String sn= br.readLine();
        int a[]= new int[n];
        String str2[]= sn.trim().split("\\s");
        int i;
        for(i=0;i<n;i++)
        {
            a[i]= Integer.parseInt(str2[i]);
        }
        Arrays.sort(a);
        int c=0;
        for(i=n-1;i>=0;i--)
        {
       if ((a[i]-a[0])<=d)
       break;
       else
       c++;
    }
        System.out.println(c);
    }
}