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

public class Employee {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int d=scan.nextInt();
		ArrayList<Integer> arr=new ArrayList<>();
		for(int i=0;i<n;i++) {
			arr.add(scan.nextInt());
			
		}
		Collections.sort(arr);
		int num=0;
		for(int i=1;i<n;i++) {
			if(arr.get(i)-arr.get(0)>d) {
				num=arr.size()-i;
				break;
			}
		}
		System.out.print(num);
	}

}
