#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, d, a[N], b[N], ans, mn;
int read() {
  int out = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    out = (out << 1) + (out << 3) + c - '0';
    c = getchar();
  }
  return out * f;
}
int main() {
  n = read(), d = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) b[a[i]] = i;
  mn = a[n];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= d && a[i] + j <= mn; j++)
      if (b[a[i] + j]) {
        if (!j)
          ans = max(ans, b[a[i]] - b[a[i - 1]]);
        else
          ans = max(ans, b[a[i] + j] - b[a[i]] + 1);
      }
  printf("%d", n - ans);
  return 0;
}
