import java.util.*;

import static java.lang.System.in;

public class PointsOntheLine {

    public static void main(String[] args) {
        Scanner scan = new Scanner(in);
        int n = scan.nextInt(), d = scan.nextInt();

//        int [] a = new int[n];
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(scan.nextInt());
        }

        if (d == 0 || n == 1)
        {
            System.out.println(0);
            return;
        }

        HashMap<Integer, Integer> counter = new HashMap<>();
        for (int i = 0; i < n; i++) {

            int item = a.get(i);

            counter.put(item, 0);

            for (int j = 0; j <n; j++) {
                if (i != j)
                {
                    if (Math.abs(a.get(i)-a.get(j)) > d)
                    {
                        counter.put(item, counter.get(item)+1);
                    }
                }
            }
        }


        List<Map.Entry<Integer, Integer>> sortedEntries = sortMapByValues(counter);

        for (Map.Entry<Integer,Integer> entry :sortedEntries)
        {
            Collections.sort(a);
//            System.out.println(entry);
            int key = entry.getKey();
            int max = a.get(a.size()-1);
            int min = a.get(0);
            if (key == max)
            {
                if (key - min> d)
                {
                    a.remove(Integer.valueOf(max));
                }
            }
            else if (key == min)
            {
                if (max - key > d)
                {
                    a.remove(Integer.valueOf(min));
                }
            }
            else{
                if (key - min> d)
                {
                    a.remove(Integer.valueOf(max));
                }
                else if (max - key > d)
                {
                    a.remove(Integer.valueOf(min));
                }
            }
        }

        System.out.println(n-a.size());

    }

    private static List<Map.Entry<Integer, Integer>> sortMapByValues(HashMap<Integer,Integer> map){
        Set<Map.Entry<Integer, Integer>> set = map.entrySet();
        List<Map.Entry<Integer, Integer>> lItemValues = new ArrayList<>(set);
        lItemValues.sort((o1, o2) -> (o2.getValue()).compareTo(o1.getValue()));

        return lItemValues;
    }

}