def ii():
		return map(int, raw_input().split())

n,d = ii()
points = ii()
points.sort()

ans = n

for i in xrange(n):
	temp = 0
	for ele in points[::-1]:
		if (ele-points[i]) <= d:
			break
		else:
			temp += 1

	ans = min(ans, i+temp)

print ans