
n,d=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l=sorted(l)
c=0
z=l[n-1]-l[0]
if n==1 and l[0] > d:
	print (1)
elif n==1 and l[0] < d:
	print (0)
else:
	while z>d:
		c+=1
		if l[1]-l[0] > l[-1]-l[-2]:
			l.pop(0)
		else:
			l.pop(-1)
		z=l[-1]-l[0]
	if len(l)==1 and l[0] > d:
		print (c+1)
	else:
		print (c)