#include "iostream"
#include "conio.h"
#include "math.h"
#include "stdlib.h"
#include "time.h"
#include "vector"
#include "algorithm" 
#include "numeric"
#include "string"
#include "ctime"
#define sp << " "
#define sps << " " <<
#define lnl << endl <<
#define ln << endl
typedef long long ll;
using namespace std;



int main()
{
	int n, d, cnt = 0, s;
	cin >> n >> d;
	vector<int>a(n);

	s = n - 1;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	while (a[s] - a[0] > d)
	{
		s--;
		cnt++;
		a.resize(a.size() - 1);
	}
	cout << cnt;
}