#include <bits/stdc++.h>
using namespace std;
int arr[105];
int main() {
  int n, d;
  scanf("%d %d", &n, &d);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int ans = 1e9;
  int count = 0;
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    count = 0;
    for (int j = i; j < n; j++) {
      count++;
      if (arr[j] - arr[i] <= d) ans = min(ans, n - count);
    }
  }
  cout << ans << endl;
  return 0;
}
