class POAL:

    def main(self):

        self.num, self.diameter = map(int,input().strip().split(" "))
        self.inp = [int(x) for x in input().split()]
        self.inp.sort()
        self.temp = 0
        for i in range(self.num):
            self.count = 0
            for j in range(i+1,self.num):
                if((self.inp[j] - self.inp[i]) <= self.diameter):
                    self.count = self.count + 1
            if(self.temp < self.count):
                self.temp = self.count
        print(str(self.num-self.temp-1))

p = POAL()
p.main()