
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author BluLogix - Ops Team
 */
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        
        int a=in.nextInt();
        int b=in.nextInt();
        int []list=new int[a];
        for (int i = 0; i < a; i++) {
            list[i]=in.nextInt();
        }
        Arrays.sort(list);
        
        for (int i = 0; i < list.length; i++) {
            
            for (int j = list.length-1 ; j > i; j--) {
                if(list[j]-list[i]<=b){
                    System.out.println(Math.abs(j-i+1-a));
                return;
                }
                
                    
            }
        }
    }
}
