//package contest;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int d = scan.nextInt();
	int x[] = new int[101];
	for( int i = 1; i<=n ; i++)
	{
		
		int input = scan.nextInt();
		if(input<=0)
			x[input] = 0;
		else
		{
//			System.out.println("inhere");
			x[input] +=1;
		}
	}
//	for( int i =0 ; i<101; i++)
//		System.out.print(x[i]);
	int i =0;
	int countarray[] = new int[100];
	int counti = 0;
	int l= 0;
	int count =0 ;
	for( i = 1; i<101; i++)
	{
		if(l==0 && x[i]!=0)
		{
			count = 0;
			l=i;
			count+=x[i];
		}
		else if(l!=0 && x[i] !=0)
		{
			if((i-l)<=d)
				count+=x[i];
			else
			{
				l=0;
				countarray[counti] = count;
				counti++;
			}
		}
	}
//	System.out.println("count i " + counti);
//	for(  i = 0; i<counti ; i++)
//	{
//	System.out.println("borrrrr");
//		System.out.print(countarray[i]);
//	}
		int max =0;
	for( i = 0; i<counti; i++)
	{
		if( countarray[i]>max)
			max = countarray[i];
	}
//	System.out.println(max);
	if(counti!=0)
		System.out.println(n - max);
	else
		System.out.println(counti);
	scan.close();
}
}
