n,d=[int(y) for y in input().split()]
x=[int(y) for y in input().split()]
x.sort()
ans=1000
ada=0
for i in range(0,n):
	ada=0
	for j in range(i+1,n):
		if (x[j]-x[i])>d:
			ada=1
			ans=min(ans,(n-i)-(j-i)+i)
			break
	if ada==0: ans=min(ans,i)		
print(ans)