#include <bits/stdc++.h>
using namespace std;
int n, d, c, t, v, ans = 10000;
int main() {
  cin >> n >> d;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (n == 1) {
    cout << "0";
    return 0;
  }
  int b[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      b[i][j] = 0;
      if (j > i) b[i][j] = a[j - 1] - a[i - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (b[i][j] == d) {
        c = n - j + i - 1;
        if (ans > c) ans = c;
      }
    }
  }
  cout << ans;
}
