#include <bits/stdc++.h>
using namespace std;
const unsigned int mod = 1e7 + 7;
const long long int N = 1e5;
bool visit[100009] = {false};
long long int ans;
vector<long long int> v[100009];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int l, n, x = 0, p, q, y, m, lo[2009], ans = -1, sum = 0,
                      k = INT_MAX, t = 2, z = 0, w = 0, pre = 1e5, mid,
                      h[49] = {0}, a[4000] = {0}, t1 = 0, t2, now, r = 0, i = 0,
                      j = 0, flag = 0, temp = 0, e = 1e4, o = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != j) {
        if (abs(a[i] - a[j]) <= k) {
          if (ans < abs(a[i] - a[j])) {
            ans = abs(a[i] - a[j]);
            p = a[i];
            q = a[j];
          }
        }
      }
    }
  }
  x = min(p, q);
  y = max(p, q);
  for (i = 0; i < n; i++) {
    if (a[i] >= x && a[i] <= y) sum++;
  }
  cout << n - sum;
  return 0;
}
