line1 = [int(s) for s in input().split(" ")]
line2 = [int(s) for s in input().split(" ")]

n = line1[0]
d = line1[1]

points = line2

points.sort()

i = 0
min = len(points)

while i < len(points) - 1:
    j = i + 1

    while j < len(points):
        if points[j] - points[i] > d:
            break;
        j += 1

    if len(points) - ( j - i) < min:
        min = len(points) - ( j - i)

    i += 1

print(min)