#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, d;
  cin >> n >> d;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = n - 1; j > i; j--) {
      if (a[j] - a[i] == d) {
        cout << n - j - 1 << "\n";
        return 0;
      }
    }
  }
  return 0;
}
