n,d = map(int,input().split(' '))
x = input().split(' ')
x = [int(i) for i in x]
x = sorted(x)
if n <= 1:
    print(0)
else:
    m = 0
    for i in range(0,n):
        for j in range(i,n):
            if x[j]-x[i]<= d:
                m = max(m,j-i+1)
    print(n - m) 