#include <bits/stdc++.h>
using namespace std;
int MOD = 1000003;
double dis(pair<double, double> a, pair<double, double> b) {
  return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}
void file() {}
long long pw(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power & 1) {
      result = (result * base) % MOD;
    }
    base = (base * base) % MOD;
    power >>= 1;
  }
  return result;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, d;
  cin >> n >> d;
  int mn = INT_MAX, mx = -1;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (abs(v[i] - v[j]) <= d) mn = min(abs(n - j - 1 + i), mn);
    }
  }
  cout << mn << "\n";
}
