    import java.util.*;
    public class PointsOnTheLine {
        public static void main(String[] a) {
            Scanner s=new Scanner(System.in);
            int n=s.nextInt(),d=s.nextInt(),sum=0,m=0;
            int[] D=new int[101];
            for(int i=0;i<n;i++) D[s.nextInt()]++;
            for(int i=1;i<=100;i++) {
                sum+=D[i]-D[Math.max(0,i-d-1)];
                m=Math.max(sum,m);
            }
            System.out.println(n-m);
        }
    }