n, d = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
l = 0
r = n - 1
while a[r] - a[l] > d:
	if(a[r] - a[r - 1] >= a[l + 1] - a[l]):
		r -= 1
	else:
		l += 1
print(n - (r - l + 1))