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 = 0
if len(points) >= 3:
    while abs(points[0] - points[-1]) > d and len(points) >= 2:
        if abs(points[0] - points[-2]) > abs(points[1] - points[-1]):
            del points[0]
        else:
            del points[-1]
        to_remove += 1

elif len(points) == 2 and abs(points[0] - points[-1]) > d:
    to_remove = 1
print(to_remove)