n, d = map(int, input().split());nums, mx, freq = map(int, input().split()), 0, [0 for i in range(105)]
for num in nums:
    freq[num] += 1
for i in range(1, 102):
    freq[i] += freq[i-1]
d += 1
for i in range(d, 102):
	mx = max(mx, freq[i]-freq[i-d])
print(n-mx)