
import java.io.*;
import java.util.*;
public class Pointsontheline {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String str[]=br.readLine().split(" ");
		int n=Integer.parseInt(str[0]);
		int d=Integer.parseInt(str[1]);
		
		int arr[]=Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		Arrays.sort(arr);
		int l=0;
		int r=n-1;
		int count=0;
		while(l<r) {
			if(arr[r]-arr[l]>d) {
				count++;
				if(d-arr[l]>arr[r]-d) {
					l++;
				}
				
				else
					r--;
				
			}
			
			else
				break;
		}
		
		System.out.println(count);
	}

}
