#include <bits/stdc++.h>
using namespace std;
int arr[120];
int main() {
  int n, a, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr + n);
  int ans = 2000, t1, t2;
  for (int i = 0; i < n; i++) {
    t1 = arr[i] + m;
    int temp = 0;
    for (int j = i; j < n; j++) {
      if (arr[j] <= t1)
        temp++;
      else
        break;
    }
    ans = min(ans, abs(temp - n));
  }
  cout << ans << endl;
  return 0;
}
