n , d = map(int,input().split())
l = list(map(int,input().split()))
l.sort()

r = 0
d2= 0

for i in range(n):
    for j in range(n):
        d2 = l[j] - l[i]
        if d2 <= d and j - i + 1   > r:
            r = j - i + 1
            #print(r)


print( n - r)


