#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
int main() {
  long long int n, d, i, j;
  while (cin >> n >> d) {
    long long int a[n + 5];
    for (i = 0; i < n; i++) scanf("%lld", &a[i]);
    sort(a, a + n);
    long long int cn = 0;
    long long int cn1 = 0;
    map<long long int, long long int> mp, mp1;
    for (i = 0; i < n; i++) {
      if (mp[i] == 1) continue;
      for (j = i; j < n; j++) {
        if (a[j] - a[i] > d) {
          if (mp[j] == 0) cn++;
          mp[j] = 1;
        }
      }
    }
    for (i = n - 1; i >= 0; i--) {
      if (mp1[i] == 1) continue;
      for (j = i; j >= 0; j--) {
        if (a[i] - a[j] > d) {
          if (mp1[j] == 0) cn1++;
          mp1[j] = 1;
        }
      }
    }
    cout << min(cn, cn1) << endl;
  }
  return 0;
}
