n, e = [int(i) for i in str(raw_input()).split()]
l = [int(i) for i in str(raw_input()).split()]
d = dict()
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
l = sorted(d.items(), key=lambda t: t[0])
tests = set()
for i in range(len(l)- 1, -1, -1):
	for j in range(0, i + 1):
		if l[i][0] - l[j][0] <= e:
			tests.add(sum([t[1] for t in l[:j]]) + sum([t[1] for t in l[i + 1:]]))
			break
print min(tests)
