n, d = map(int, input().split())
mas = list(map(int, input().split()))
mas.sort()
mas.reverse()
fas = []
for a in range(n):
    for b in range(a, n):
        if mas[a] - mas[b] <= d:
            fas.append(a + n - b - 1)
if len(fas) == 0:
    print(0)
else:
    print(min(fas))
