#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int points[n];
  for (int i = 0; i < n; i++) {
    cin >> points[i];
  }
  sort(points, points + n);
  int diff[n - 1];
  for (int i = 0; i < n - 1; i++) {
    diff[i] = points[i + 1] - points[i];
  }
  int left = 0, right = n - 1;
  int diameter = points[right] - points[left];
  right -= 1;
  int result = 0;
  while (diameter > d && (right - left) > 0) {
    if (diff[left] > diff[right]) {
      diameter -= diff[left];
      left += 1;
    } else {
      diameter -= diff[right];
      right -= 1;
    }
    result += 1;
  }
  if (right == left || diameter == d) {
    cout << result;
    return 0;
  }
  left -= 1;
  right += 1;
  bool removed = false;
  while (diameter <= d && (left >= 0 || right < n - 1)) {
    if (left >= 0 && (right == n - 1 || diff[left] <= diff[right])) {
      diameter += diff[left];
      left -= 1;
    } else if (right < n - 1 && (left == 0 || diff[left] >= diff[right])) {
      diameter += diff[right];
      right += 1;
    }
    result -= 1;
    removed = true;
  }
  cout << result + (int)(removed);
  return 0;
}
