#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int a[n];
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  int c;
  for (i = 0; i < n - 1; i++) {
    c = 0;
    for (j = i + 1; j < n; j++) {
      if (abs(a[i] - a[j]) <= d) {
        c++;
      } else {
        break;
      }
    }
    if (count < c) {
      count = c;
    }
  }
  cout << (n - count - 1) << endl;
  return 0;
}
