n, x = map(int, input().split())

arr = list(map(int, input().split()))

arr.sort()

res = 100000000000;
for i in range(n):
    for j in range(i,n):
        if arr[j] - arr[i] <= x:
            res = min(res,n-(abs(i-j)+1))
print(res)