import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class A_PointsontheLine {


    public static int getMaxValue(int[] numbers){
        int maxValue = numbers[0];
        for(int i=1;i < numbers.length;i++){
            if(numbers[i] > maxValue){
                maxValue = numbers[i];
            }
        }
        return maxValue;
    }
    public static int getMinValue(int[] numbers){
        int minValue = numbers[0];
        for(int i=1;i<numbers.length;i++){
            if(numbers[i] < minValue){
                minValue = numbers[i];
            }
        }
        return minValue;
    }

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n,d;

        String s = reader.readLine();
        String[] inp = s.split(" ");

        n = Integer.parseInt(inp[0]);
        d= Integer.parseInt(inp[1]);

        int[] arr = new int[n];


        String f = reader.readLine();
        String[] inp1 = f.split(" ");

        for(int i=0;i<arr.length;i++)
        {
            arr[i]=Integer.parseInt(inp1[i]);
        }

        Arrays.sort(arr);

        int max,min,diff;

        max = getMaxValue(arr);
        min = getMinValue(arr);

        diff = max-min;
        int first = arr[0];
        int sum=0;

        for(int i =arr.length-1;i>=0;i--)
        {
            int p = arr[i];

            if((p-first)>d) {
                sum += 1;
            }
        }

        if(n==1)
            System.out.print(0);
        else
            System.out.print(sum);
    }
}