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

import javax.swing.JOptionPane;
public class Lessom {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		int quantity = in.nextInt();
		int findLess = in.nextInt();
		for(int i = 0;i<quantity;i++) {
			int k = in.nextInt();
			list.add(k);
		}
		int fAnswer = first(quantity,findLess,list);
		int sAnswer = first(quantity,findLess,list);
		int k = Math.max(sAnswer,fAnswer);
		System.out.print(k);
	}
	public static int first(int quantity,int findLess,List<Integer> list) {
		int max = Collections.max(list);
		int min = Collections.min(list);
		int answer = 0;
		while((max-min)>findLess) {
			list.remove(list.indexOf(Collections.max(list)));
			max = Collections.max(list);
			min = Collections.min(list);
			answer++;
		}
		return answer;
	}
	public static int second(int quantity,int findLess,List<Integer> list) {
		int max = Collections.max(list);
		int min = Collections.min(list);
		int answer = 0;
		while((max-min)>findLess) {
			list.remove(list.indexOf(Collections.min(list)));
			max = Collections.max(list);
			min = Collections.min(list);
			answer++;
		}
		return answer;
	}
		
}