nd = input().split(' ')
n, d = int(nd[0]), int(nd[1])
points = input().split(' ')

for p in range(len(points)):
    points[p] = int(points[p])

points.sort()
to_remove = []
l = len(points)
for i in range(l):
    for j in range(l):
        if abs(points[i] - points[j]) <= d:
            to_remove.append(l - (i-j+1))

print(min(to_remove))