#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, d, m, x, y;
  cin >> n >> d;
  int arr[n + 1];
  for (int i = (1); i <= (n); ++i) cin >> arr[i];
  sort(arr + 1, arr + 1 + n);
  int left = 1;
  int right = n;
  int cnt = 0;
  while (1) {
    int curr = abs(arr[left] - arr[right]);
    if (curr == 0) {
      cout << cnt << endl;
      return 0;
      break;
    }
    int nr = abs(arr[left] - arr[right - 1]);
    int nl = abs(arr[left + 1] - arr[right]);
    if (curr > d) {
      if (nr <= nl) {
        right--;
      } else
        left++;
      cnt++;
    } else
      break;
  }
  cout << cnt << "\n";
  return 0;
}
