import java.util.*;

public class Code1 
{

	public static void main(String[] args) 
	{
	
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), d = scan.nextInt(), i, j, total = 0;
		ArrayList<Integer> arr = new ArrayList<Integer>();
		for(i = 0 ; i < n ; i++)
			arr.add(scan.nextInt());
		Collections.sort(arr);
		for(i = 0 ; i < n ; i++)
		{
			int num = 1;
			for(j = i + 1 ; j < n ; j++)
			{
				if(arr.get(j) - arr.get(i) <= d)	num++;
				else										break;
			}
			if(num > total)	total = num;
		}
		System.out.println(n - total);
		scan.close();
	}
}