

import java.util.*;


import java.io.*;
public class Solution {
	static FastScanner scr=new FastScanner();
	static PrintStream out=new PrintStream(System.out);
	static StringBuilder sb=new StringBuilder();
	
	static int gcd(int a,int b){
		if(b==0) {
			return a;
		}
			
		return gcd(b,a%b);
	}
	static void print(int ele) {
		sb.append(ele).append(" ");
	}
	static void println(int ele) {
//		AccessBridge.
		sb.append(ele).append('\n');
		
	}
	static void println() {
		sb.append('\n');
	}
	static long modPow(long base,long exp,long mod) {
		if(exp==0) {
			return 1;
		}
		if(exp%2==0) {
			long res=(modPow(base,exp/2,mod));
			return (res*res)%mod;
		}
		return (base*modPow(base,exp-1,mod))%mod;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
	 	String next() {
	 		while (!st.hasMoreTokens())
	 			try {
	 				st=new StringTokenizer(br.readLine());
	 			} catch (IOException e) {
	 				e.printStackTrace();
	 			}
	 			return st.nextToken();
		}
		int[] sort(int a[]) {
			Arrays.sort(a);
			return a;
		}
		int []reverse(int a[]){
			int b[]=new int[a.length];
			int index=0;
			for(int i=a.length-1;i>=0;i--) {
				b[index]=a[i];
			}
			return b;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long  [] a=new long  [n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	static ArrayList<Integer>list[];
	static void solve() {
		
		int n=scr.nextInt();
		int d=scr.nextInt();
		int []a=scr.readArray(n);
		
		Arrays.sort(a);
		
		int remove=0;
		for(int i=0;i<n;i++) {
			for(int j=n-1;j>=i;j--) {
				if(a[j]-a[i]<=d) {
					remove=Math.max(remove,j-i+1);
				}
			}
		}
		out.println(n-remove);
	}
	static int  MAX=Integer.MAX_VALUE;
	static int  MIN=Integer.MIN_VALUE;
	public static void main(String []args) {
//		int t=scr.nextInt();
//		while(t-->0) {
			solve();
//		}
//		out.println(sb);
	}
}
