import java.io.*;
import java.util.*;

import org.w3c.dom.css.Counter;

public class PointsOnTheLine {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws IOException {
        FastReader scan = new FastReader();
        int n = scan.nextInt(), d = scan.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scan.nextInt();
        }
        int counter[] = new int[n];
        for (int i = 0; i < counter.length; i++) {
            counter[i] = 0;
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < counter.length; j++) {
                if (Math.abs(arr[i] - arr[j]) > d) {
                    counter[i]++;
                    counter[j]++;
                }
            }
        }
        Arrays.sort(counter);
        int checker = counter[0], count = 0;
        for (int i = 0; i < counter.length; i++) {
            if (counter[i] == checker) {
                count++;
            }
        }
        System.out.println(n - count);
    }
}
