#include <bits/stdc++.h>
using namespace std;
int N, D;
int a[105];
queue<int> q;
int main() {
  cin >> N >> D;
  for (int i = 1; i <= N; i++) cin >> a[i];
  int flag = a[1];
  bool F = true;
  for (int i = 1; i <= N; i++) {
    if (flag != a[i]) F = false;
  }
  if (F == true) {
    cout << 0;
    return 0;
  }
  sort(a + 1, a + 1 + N);
  q.push(1);
  int ans = 1;
  for (int i = 2; i <= N; i++) {
    while (!q.empty() && a[i] - a[q.front()] > D) q.pop();
    q.push(i);
    int size = int(q.size());
    ans = max(ans, size);
  }
  cout << N - ans;
  return 0;
}
