from sys import *
n,k=[int(x) for x in input().split()]
s=input()
d=list()
for x in s.split(): d.append(int(x))
d.sort()#;check=False
for i in range(len(d),0,-1):
    #if check: break
    j=0
    while i+j-1<len(d):
        #if check: break
        if d[i+j-1]-d[j]<=k: print(len(d)-i);exit()
        j+=1
        
        
