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

public class Oddiy {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int d = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		
		int res = 0;
		int i = n-1;
		if(d==0) {
			System.out.println(n);
		}
		else {
		 while(a[i]-a[0]>d ) {
			 i--;
			 res++;
		 }
		System.out.println(res);
		}
	}
}
