import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Lessom {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int quantity = in.nextInt();
		int findLess = in.nextInt();
		for(int i = 0;i<quantity;i++) {
			int k = in.nextInt();
			list.add(k);
		}
		Collections.sort(list);
		int answer = Integer.MAX_VALUE;
		for(int i = 0;i<quantity;i++) {
			for(int j = i;j<quantity;j++) {
				if((list.get(j)-list.get(i)) <= findLess) {
					int kolvo = quantity-(j-i+1);
					if(answer>kolvo)answer = kolvo;
				}
			}
		}
		System.out.print(""+answer);
	}
}