n, d = map(int, input().split())
a = list(map(int, input().split()))
k = 0
a = sorted(a)
b = a[:]
diam1 = a[-1] - a[0]
diam2 = b[-1] - b[0]
while diam1 > d and diam2 > d:
    a.pop(0)
    b.pop(-1)
    diam1 = a[-1] - a[0]
    diam2 = b[-1] - b[0]
    k += 1
print(k)