import java.util.Arrays;
import java.util.Scanner;


public class CodeForcesSolution {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int gap = scanner.nextInt();
			int[] array = new int[N];
			
			for(int i = 0; i < N; i++) {
				array[i] = scanner.nextInt();
			}
			
			
			Arrays.sort(array);
			
			
			int i = 0;
			int j = 1;
			int count = 1;
			
			while(j < array.length) {
				if(array[j] - array[i] <= gap) {
					count++;
					++j;
				} else {
					i++;
					++j;
				}
			}
			
			System.out.println(array.length-count);
		}
	}
}
