n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
b = a[::-1]
i = 0
r1 = 0
r2 = 0

while True:
	if abs(a[i] - a[-1]) > d:
		a.pop()
		r1 += 1
	else:
		print(r1)
		break
	if abs(b[i] - b[-1]) > d:
		b.pop()
		r2 += 1
	else:
		break
