import java.util.*;
public class A{
       public static void main(String args[]){
              Scanner sc = new Scanner(System.in);
              int n = sc.nextInt();
              int k = sc.nextInt();
              int a[] = new int[n];
              for(int i = 0; i < n; i++)
                     a[i] = sc.nextInt();
              Arrays.sort(a);
              int min = Integer.MAX_VALUE;
              for(int i = 0; i < n; i++){
                     for(int j = i; j < n; j++){
                            if(a[j] - a[i] <= k)
                                   min = Math.min(min, a.length - (j - i + 1));
                     }
              }
              System.out.println(min);
       }
}