import java.util.*;
import java.io.*;
public class A940
{
	public static void main(String args[]) throws Exception
	{
		BufferedReader f;
		try
		{
			f=new BufferedReader(new FileReader("A940.in"));
		}
		catch(Exception e)
		{
			f=new BufferedReader(new InputStreamReader(System.in));
		}
		StringTokenizer st=new StringTokenizer(f.readLine());
		int runs=Integer.parseInt(st.nextToken());
		int val=Integer.parseInt(st.nextToken());
		int[] arr=new int[runs];
		st=new StringTokenizer(f.readLine());
		for(int x=0;x<runs;x++)
			arr[x]=Integer.parseInt(st.nextToken());
		Arrays.sort(arr);
		int min=1<<20;
		for(int x=0;x<runs;x++)
			for(int y=x;y<runs;y++)
			{
				if(arr[y]-arr[x]>val) break;
				min=Math.min(min,runs-(y-x+1));
			}
		System.out.println(min);
	}
}