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

public class CF_466C {

	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = null;
        
        int n = nextInt();
        int d = nextInt();
        
        int[] a = new int[n];
        for(int i = 0 ;i < n;i++)
        	a[i] = nextInt();
        Arrays.sort(a);
        
        int min = n;
        for(int i = 0 ; i < n;i++)
        	for(int len = 1; len <= n-i;len++)
        	{
        		if(a[i+len-1]-a[i] <= d)
        		{
        			min = Math.min(n-len, min);
        		}
        	}
        System.out.println(min);
	}
	

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static long nextLong() throws IOException
    {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException
    {
        return Double.parseDouble(nextToken());
    }

    static int nextInt() throws IOException
    {
        return Integer.parseInt(nextToken());
    }

    static String nextToken() throws IOException
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }


}
