from sys import stdin, stdout
ti = lambda : stdin.readline().strip()
ma = lambda fxn, ti : map(fxn, ti.split())
ol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\n')
os = lambda i : stdout.write(str(i) + '\n')
olws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\n')

n, d = ma(int, ti())
x = ma(int, ti())
x.sort(reverse=True)
if n == 1:
	os(0)
	exit()

ans = 0
while x[0] - x[n-1] > d:
	if x[n-2] - x[n-1] > x[0] - x[1]:
		x.pop(n-1)
	else:
		x.pop(0)
	n -= 1
	ans += 1
os(ans)