//import java.lang.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int d = scanner.nextInt();
		int [] arr = new int[n];
		for(int i = 0; i < n; ++i)
			arr[i] = scanner.nextInt();
		
		Arrays.sort(arr);
		int cnt = 0;
		int minMove = 200;
		for (int i = 0; i < n; i++)
		{
			cnt = i;
			for (int j = n-1; j >= 0; j--)
			{
				if (arr[j] - arr[i] <= d)
				{
					break;
				}
				cnt++;
			}
			if (cnt < minMove)
				minMove = cnt;
		}
		if (minMove == n)
			minMove--;
		System.out.println(minMove);
		scanner.close();
	} // end main
	
}