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

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int d = cin.nextInt();
		
		int[] arr = new int[n];
		for(int i = 0; i < n; i++)
			arr[i] = cin.nextInt();
		
		Arrays.sort(arr);
		int MAX = arr[0] + d;
		for(int i = 0; i < n; i++)
			if(arr[i]>MAX) {
				System.out.print(n-i);
				return;
			}		
		System.out.print(0);		
	}
}
