#include <bits/stdc++.h>
void merge(int a[], int lo, int hi) {
  int *temp = (int *)malloc(sizeof(int) * (hi - lo + 1));
  int m = (hi + lo) / 2;
  int inx = 0, p1 = lo, p2 = m + 1;
  while (p1 <= m && p2 <= hi) {
    temp[inx++] = (a[p1] <= a[p2]) ? a[p1++] : a[p2++];
  }
  while (p1 <= m) {
    temp[inx++] = a[p1++];
  }
  while (p2 <= hi) {
    temp[inx++] = a[p2++];
  }
  for (int i = 0; i < inx; i++) a[i + lo] = temp[i];
}
void MS(int a[], int lo, int hi) {
  if (lo == hi) return;
  int m = (lo + hi) / 2;
  MS(a, lo, m);
  MS(a, m + 1, hi);
  merge(a, lo, hi);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int *a = (int *)malloc(sizeof(int) * n);
  int i;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  MS(a, 0, n - 1);
  int j = 0;
  i = n - 1;
  int c = 0;
  for (i = n - 1; i >= 0; i--) {
    if (a[i] - a[j] > m) {
      c++;
    } else
      break;
  }
  printf("%d", c);
  return 0;
}
