n, d = list(map(int, input().split()))
x = sorted(list(map(int, input().split())))
o = 0
if n == 1:
    print(0)
    exit()

while max(x) - min(x) > d:
    if max(x) - x[1] < x[-2] - min(x):
        x.pop(0)
        o += 1
    else:
        o += 1
        x.pop()

print(o)