para = map(int, raw_input().split())
n = para[0]
d = para[1]
line = map(int, raw_input().split())
line.sort()
out = []
for i in range(n):
	cnt = 0
	for j in range(n):
		if line[j] in range(line[i], line[i] + d + 1):
			cnt += 1
	out.append(cnt)
print n - max(out)