#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;
	cin >> n >> d;
	vector<int>a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	for(int i=n-1;i>=0;--i)
		if (a[i] - a[0] <= d)
		{
			cout << n - i - 1;
			return 0;
		}
}
