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

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