#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  int ans = 0, cnt = n;
  while (a[cnt] - a[1] > d) {
    ans++;
    cnt--;
  }
  cout << ans;
}
