# input() reads a string with a line of input, stripping the '\n' (newline) at the end.
# This is all you need for most Code Jam problems.
def find(points, i, j):
    if (i >= j):
        return 0
    if (points[j] - points[i]) > diameter:
        result1 = find(points, i + 1, j) + 1
        result2 = find(points, i, j - 1) + 1
        return min(result1, result2)
    else:
        return 0


pairs= [int(s) for s in input().split(" ")]
num = pairs[0]
diameter = pairs[1]
points= [int(s) for s in input().split(" ")]
points.sort()
answer = 101
for i in range(num):
    cur =points[i]
    point = next((x[0] for x in enumerate(points) if x[1] > (cur+diameter)), num)
    answer = min(answer,(i + num - point))


print(answer)