n,k = map(int,raw_input().split())
arr = map(int,raw_input().split())
arr.sort()
maxlength = 0
for i in range(n-1):
    for j in range(i+1,n):
        if arr[j]-arr[i]<=k and j-i > maxlength:
            maxlength = j-i
print n-(maxlength+1)