n, d = [int(i) for i in raw_input().split(' ')]
xs = [int(i) for i in raw_input().split(' ')]
xs = sorted(xs, reverse=True)
n = 0
while xs[n] - xs[-1] > d:
    n += 1
xs = xs[::-1]
k = 0
while xs[-1] - xs[k] > d:
    k += 1
print min(n, k)