#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
inline int read() {
  int sum = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') sum = sum * 10 + c - 48, c = getchar();
  return sum * f;
}
int n, d, x[N], minn = INF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= 100; i++) {
    int j = i + d, cnt = 0;
    for (int k = 1; k <= n; k++) {
      if (x[k] < i || x[k] > j) cnt++;
    }
    minn = min(minn, cnt);
    ;
  }
  cout << minn << '\n';
  return 0;
}
