#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  ;
  int n, d;
  cin >> n >> d;
  int a[105];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int m = a[0], h = a[n - 1];
  int u = 100;
  if (h - m <= d) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (h - a[i] <= d) {
      u = i;
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    int y = n - i - 1;
    if (a[y] - m <= d) {
      u = min(u, n - y - 1);
      break;
    }
  }
  cout << u;
}
int32_t main() { solve(); }
