import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int [] arr=  new int[n];
		
		for (int i =0;i<n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.sort(arr);
		
		int i=0;
		int min=Integer.MAX_VALUE;
		for(int j=0;j<n;j++){
			for(i=0;i<n;i++){
				if(arr[i]-arr[j]>d){
					break;
				}
			}
			min=Math.min(n-i+j,min);
		}
		System.out.println(min);
		
		sc.close();

	}

}