def diam(data):
    return data[-1] - data[0]


n, d = [int(i) for i in input().split()]
data = sorted(list(set(map(int, input().split()))))
k = 0
while diam(data) > d:
    if data[1] - data[0] > data[-1] - data[-2]:
        del data[0]
    else:
        del data[-1]
    k += 1
print(k)




# Sat Nov 23 2019 11:30:04 GMT+0300 (MSK)
