n, d = [int(s) for s in input().split(' ')]
x = [int(s) for s in input().split(' ')]
x.sort()
steps = 0
while x[-1] - x[0] > d:
    steps += 1
    if len(x) > 2:
        if x[1] - x[0] > x[-1] - x[-2]:
            del x[0]
        else:
            del x[-1]
    else:
        del x[0]
print(steps)
