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 multiset[] = new int[n];
		
		for(int i=0; i<n; i++)
		{
			multiset[i] = sc.nextInt();
		}
		
		int baad = 0;
		int minimum = 1000;
		
		for(int i=0; i<n; i++)
		{
			int u = multiset[i];
			int count = 0;
			
			for(int j=0; j<n; j++)
			{
				int v= multiset[j];
				
				if(v<u) continue;
				
				if( (v-u) <= d) 
				{
					count++;
				}
			}
			
			baad = n- count;
			
			if( minimum>baad ) 
			{
				minimum = baad;
			}
		}
		
		
		
		System.out.println(minimum);
	}
}
