import java.io.*;
import java.util.*;
public class codeforces1
{    
    static int n;
    static int d;
    static int arr[];
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        d=sc.nextInt();
        arr=new int[n];
        int freq[]=new int[800];
        for(int i = 0;i<n;i++)
        {
            arr[i]=sc.nextInt();
            freq[arr[i]]++;
        }
        Arrays.sort(arr);
        int ans=0;
        for(int i = 1;i<=100;i++)
        {
            int count=0;
            for(int j =i;j<=i+d;j++)
            {
                count+=freq[j];
            }
            ans=Math.max(count,ans);
        }
        System.out.println(n-ans);
        
    }
}