

import java.math.BigInteger;
import java.util.*;


public class Main {
    
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        
         int n = input.nextInt();
         int k = input.nextInt();
         int result[] = new int[101];
         Arrays.fill(result, 0);
         int maxInput=0;
         for (int i = 0; i < n; i++) {
             int x = input.nextInt();
            result[x]++;
            maxInput=Math.max(maxInput, x);
            
        }
        
         int k1=k;
         int max =0;
         for (int i = 1; i <=maxInput; i++) {
             k=k1;
             int sum=0;
            if(result[i]>0)
            {
                int j=i;
                while(k-->=0 &&j<=maxInput)
                {
                   sum+=result[j]; 
                    j++;
                }
                
                max = Math.max(max,sum);
                
            }
        }
         System.out.println(n-max);
        
    }

   
    
    
}

