#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int arr[n];
  map<int, int> mapp, mark;
  for (int i = 0; i < n; i += 1) {
    cin >> arr[i];
    mapp[arr[i]] = 0;
    mark[arr[i]] = 0;
  }
  vector<int> vec;
  for (int i = 0; i < n; i += 1) {
    if (mapp[arr[i]] == 0) {
      vec.push_back(arr[i]);
    }
    mapp[arr[i]] += 1;
  }
  sort(vec.begin(), vec.end());
  int len = vec.size();
  int c1 = 0, c2 = 0;
  for (int i = 0; i < len - 1; i += 1) {
    for (int j = i + 1; j < len; j += 1) {
      if (vec[j] - vec[i] > d) {
        c1 += mapp[vec[i]];
        break;
      }
    }
  }
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < len - 1; i += 1) {
    for (int j = i + 1; j < len; j += 1) {
      if (vec[i] - vec[j] > d) {
        c2 += mapp[vec[i]];
        break;
      }
    }
  }
  if (c1 > c2) {
    cout << c2;
  } else {
    cout << c1;
  }
}
