import java.util.* ;

public class A {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int si,lim,i,j,count;
		si = sc.nextInt() ;
		lim = sc.nextInt() ;
		int[] arr = new int[si] ;
		int[] a = new int[si] ;
		Arrays.fill(a,1) ;
		for(i=0;i<si;i++) {
			arr[i] = sc.nextInt() ;
		}
		int max = Integer.MIN_VALUE ;
		Arrays.sort(arr);
		for(i=0;i<si;i++) {
			//count = 1;
			int pow = arr[i]+lim ;
			for(j=i+1;j<si;j++) {
				if(arr[j] <= pow) {
					a[i] += 1 ;
				}				
			}
			if(max < a[i]) {
				max = a[i] ;
			}
		}
		//System.out.println(i);
		System.out.println(si-max);
	}
}