import java.util.*;
import java.io.*;
public class main
{
    public static void main(String[] args) throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = (br.readLine()).trim().split(" ");
        int n = Integer.parseInt(str[0]);
        int d = Integer.parseInt(str[1]);
        str = (br.readLine()).trim().split(" ");
        int[] arr = new int[n];
        int end = Integer.MIN_VALUE;
        for(int i=0;i<n;i++)
        {
            arr[i] = Integer.parseInt(str[i]);
            if(arr[i] > end)
                end = arr[i];
        }
        int max = Integer.MIN_VALUE;
        for(int i=0;i<=end - d;i++)
        {
            int temp = 0;
            for(int j=0;j<n;j++)
            {
                if(arr[j] >= i && arr[j] <= (i+d))
                    temp++;
            }
            if(temp > max)
                max = temp;
        }
        System.out.println(n - max);
    }
}