import java.util.*;
public class atask{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt() , d = s.nextInt() ;
        int[] arr = new int[n];
        
        for(int i = 0;i < n;i++){
            arr[i] = s.nextInt();
        }
        
        Arrays.sort(arr);
        
        int count = 0;
        for(int i = n-1;i >= 0;i--){
            if(arr[i] - arr[0] > d){
                count++;
            }
            else
                break;
        }
        
        System.out.println(count);
    }
}