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