n, d = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
found = 0
for i in range(n, 0, -1):
    if found: break
    for j in range(n - i + 1):
        if l[j + i -1] - l[j] <= d:
            print(n - i)
            found = 1
            break

