n, d = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
i = 0
j = n - 1
points = 200
cpoints = 0
while i < n and l[j] - l[i] > d:
    cpoints += 1
    i += 1
points = min(points, cpoints)
i = 0
cpoints = 0
while j > 0 and l[j] - l[i] > d:
    cpoints += 1
    j -= 1
points = min(points, cpoints)
print(points)
