#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, cd;
  cin >> n >> d;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int sp = 0, ep = n - 1, ans = 0;
  cd = v[ep] - v[sp];
  while ((cd > d) && (ep - sp > 0)) {
    if ((v[sp + 1] - v[sp]) > (v[ep] - v[ep - 1])) {
      sp++;
    } else if ((v[sp + 1] - v[sp]) < (v[ep] - v[ep - 1]))
      ep--;
    else {
      int x = sp, y = ep;
      while ((x < y) && ((v[x + 1] - v[x]) == (v[y] - v[y - 1]))) {
        x++;
        y--;
      }
      if (y > x) {
        if (((v[x + 1] - v[x]) > (v[y] - v[y - 1])))
          sp++;
        else
          ep--;
      }
      if (x >= y) sp++;
    }
    ans++;
    cd = v[ep] - v[sp];
  }
  cout << ans;
  return 0;
}
