import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int d=scan.nextInt();
        int[] arr=new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i]=scan.nextInt();
        }
        Arrays.sort(arr);
        int ans=0;
        for (int i = n-1; i >0 ; i--) {
            if (arr[i]-arr[0]>d){
                ans++;
            }else {
                break;
            }
        }
        System.out.println(ans);
    }
}
