import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

@SuppressWarnings("WrongPackageStatement")
public class Test1 {

    public static void main(String[] args) {
        MyScanner scanner = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = scanner.nextInt();
        int d = scanner.nextInt();

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list);

        int currD = last(list) - list.get(0);
        int ans = 0;
        while (currD > d) {
            ans++;

            int frontDiff = list.get(1) - list.get(0);
            int backDiff = last(list) - list.get(list.size() - 2);

            if (frontDiff > backDiff) {
                list.remove(0);
            } else {
                list.remove(list.size() - 1);
            }

            currD = last(list) - list.get(0);
        }

        System.out.println(ans);
        out.close();
    }

    private static <T> T last(List<T> list) {
        return list.get(list.size() - 1);
    }

    private static class MyScanner {

        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

    }

}
