#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1000000000;
int n, d, curD, used[105];
vector<int> a(105);
int result = 1e9;
int main() {
  int x;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    used[a[i]]++;
  }
  for (int i = 1; i <= 100; i++) used[i] += used[i - 1];
  for (int i = 0; i <= 101 - d; i++)
    result = min(result, used[100] - used[i + d] + (i ? used[i - 1] : 0));
  cout << result << "\n";
  return 0;
}
