n,d = map(int,input().split())
x = list(map(int,input().split()))

x.sort()
z = -1
for i in range(n):
	y = 0
	for j in range(i,n):
		if (x[j]-x[i] <= d): 
			if j -i > z: 
				z = j - i

print(n - z - 1)

