import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class codeforces466 {

	public static void main(String[] args)
					throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		String[] xx = s.split(" ");
		int l=Integer.parseInt(xx[0]);
		int d=Integer.parseInt(xx[1]);
		s = br.readLine();
		String[] ele=s.split(" ");
		int[] arr=new int[l];
		for(int i=0;i<l;i++) {
			arr[i]=Integer.parseInt(ele[i]);
		}
		Arrays.sort(arr);
//		for(int i=0;i<l;i++) {
//			System.out.println("sdfasavs"+arr[i]);
//		}
		int ans=0;
		if((arr[l-1]-arr[0])<=d) {
			System.out.println(ans);
		}
		else {
			int st=0;
			int ls=l-1;
			while(st<=ls){
				int diff=arr[ls]-arr[st];
				if(diff<=d) {
					break;
				}
				else {
					++ans;
					if((arr[ls]-arr[ls-1]) >= (arr[st+1]-arr[st])) {
						--ls;
					}
					else {
						++st;
					}
				}
			}
			System.out.println(ans);
		}
	}

}