import java.util.*;
public class A940 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), d = in.nextInt(), arr[] = new int[n], max = 0, count = 0; 
		Set<Integer> set = new HashSet<Integer>();
		
		for(int i=0; i<n; i++)
		{
			arr[i] = in.nextInt();
			set.add(arr[i]);
		}
		
		for(int m : set)
		{
			count = 0;
			for(int i=0;i<n;i++)
				if(arr[i] <= m+d && arr[i] >= m)
					count++;
			if(count >= max)
				max = count;
		}
		
		System.out.println(arr.length - max);
	}
}
