import java.util.*;
public class Task3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] str = in.nextLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int d = Integer.parseInt(str[1]);
        String[] str1 = in.nextLine().split(" ");
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            ar[i] = Integer.parseInt(str1[i]);
        }
        Arrays.sort(ar);
        int count = 0;
        if (d == 0 || n == 1) {
            System.out.print(0);
            System.exit(0);
        }
        for (int i = n-1; i > 0; i--) {
            if (ar[i]-ar[0] > d) count++;
        }
        System.out.print(count);
    }
}
