import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] nd = br.readLine().split(" ");
		int n = Integer.parseInt(nd[0]);
		int d = Integer.parseInt(nd[1]);
		
		String[] as = br.readLine().split(" ");
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = Integer.parseInt(as[i]);
		
		Arrays.sort(a);
		
		int max = 1;
		for(int i=0; i<n-1; i++) {
			int count = 1;
			for(int j=i+1; j<n; j++) {
				if((a[j] - a[i]) <= d) ++ count;
			}
			if(count > max) max = count;
		}
		
		System.out.println(n - max);
	}
}
