#include <bits/stdc++.h>
using namespace std;
long long n, z, d, a[101], l, r;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i < n; i++) {
    if (a[i] != 0) {
      for (int j = i + 1; j <= n; j++) {
        if (a[j] != 0) {
          if (a[j] - a[i] > d) {
            z++;
            a[j] = 0;
          }
        }
      }
    }
  }
  cout << z << endl;
}
