
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int remove = 0;
        Integer points[] = new Integer[n];
        Stack st = new Stack();
        for (int j = n - 1; j >= 0; j--) {
            points[j] = in.nextInt();
        }
        Arrays.sort(points);
        st.addAll(Arrays.asList(points));
        if (n==2){
                if ((Integer) st.elementAt(st.size() - 1) != (Integer) st.elementAt(0) && d==0)
                    remove=1;
            }
        if (n > 1) {
            if((Integer) st.elementAt(st.size() - 1) == (Integer) st.elementAt(0)){
                if(d!=0){
                    int kk = (Integer) st.elementAt(st.size() - 2);
                    remove=remove +(st.size()-1);
                    st.clear();
                    st.add(kk);                   
                }
            }
            else{
            for (int i = 0; i < n && st.size()>2; i++) {
                int c1 = 0, c2 = 0;
                if ((Integer) st.elementAt(st.size() - 2) - (Integer) st.elementAt(0) >= d) {
                    c1 = (Integer) st.peek();
                }
                if ((Integer) st.peek() - (Integer) st.elementAt(1) >= d) {
                    c2 = (Integer) st.elementAt(0);
                }
                
                if (c1 == 0 && c2 == 0) {
                    break;
                } else {
                    st.removeElement(Math.max(c1, c2));
                    remove++;
                }
            }
        }
        }
        System.out.print(remove);
    }
}
