[n,m] = input().split(' ')
n = int(n)
m = int(m)

line = input().split(' ')

a = []
for i in range( n) :
    a.append(int(line[i]))
b = sorted (a )
ans = -9999
for i in range( n) :
    for j in range(i , n):
        if b[j] - b[i] <= m:
             ans  = max(ans,j-i)

print(n-ans-1)
