#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, ll> mp, mp1;
vector<pair<ll, pair<ll, ll> > > vpp1;
vector<pair<ll, ll> > vpp, vpppp1;
vector<ll> v, v1, v2, fin;
map<pair<ll, ll>, bool> mbb;
map<ll, bool> mb, mb1;
bool visited[600006 + 19];
ll a, b, c, n, d, e, f, ta, sum = 0, cnt = 0, m, l, req, sz, maxi, k, q,
                            ans = 0, x, y, tot = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> d;
  for (ll i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  ll maxi = 0;
  sort(v.begin(), v.end());
  for (ll i = 0; i < n; i++) {
    ll rt = 1, lf = 0;
    for (ll j = i + 1; j < n; j++) {
      if (abs(v[j] - v[i]) <= d) rt++;
    }
    maxi = max(maxi, rt + lf);
  }
  cout << n - maxi << endl;
  return 0;
}
