n,d=map(int,input().split())
Ar=[int(x) for x in input().split()]
Ar.sort()
h=[]
for i in range(n):
	A=Ar[i:]
	m=A[0]+d
	j=0
	while j<len(A):
		if A[j]>m:
			A.remove(A[j])
		else:
			j+=1
	h.append(len(A))
print(n-max(h))