from collections import deque

n, d = [int(s) for s in input().split()]
xs = deque(sorted(int(s) for s in input().split()))

ans = 0
while xs[-1] - xs[0] > d:
    if xs[-2] - xs[0] <= xs[-1] - xs[1]:
        xs.pop()
    else:
        xs.popleft()
    ans += 1
print(ans)
