
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static byte counter(TreeSet<Byte> list, byte d) {
        byte counter = 0;
        int currentDiameter = list.last() - list.first();

        while (currentDiameter > d) {

            list.remove((list.last() - list.higher(list.first()) < list.lower(list.last()) - list.first()) ? list.first() : list.last());

            counter++;
            currentDiameter = list.last() - list.first();
        }

        return counter;
    }

    public static void main(String[] args) throws IOException {
        //1: Declare/Define variables
        InputStreamReader reader = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(reader);
        StringTokenizer st = new StringTokenizer(in.readLine());
        byte n = Byte.parseByte(st.nextToken()), d = Byte.parseByte(st.nextToken());
        TreeSet<Byte> list = new TreeSet();

        st = new StringTokenizer(in.readLine());

        //2: Insert the numbers in the treeset
        for (byte i = 0; i < n; i++) {
            list.add(Byte.parseByte(st.nextToken()));
        }

        //3: Print the result
        System.out.println(counter(list, d));

    }
}
