#JMD
#Nagendra Jha-4096

import sys
from math import*
mod=1000000007
#a=list(map(int,input().strip().split(' ')))
#n,k,s= map(int, sys.stdin.readline().split(' '))

def coun(a,d):
    a.sort()
    if(a[-1]-a[0]<=d):return True
    else:return False

n,d= map(int, sys.stdin.readline().split(' '))
a=list(map(int,input().strip().split(' ')))
a.sort()
maxc=0
for i in range(n):
    for j in range(i,n):
        sl=a[i:j+1]
        #print(sl)
        if(coun(sl,d)):
            maxc=max(maxc,j-i+1)
print(n-maxc)



    
