import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Div2_466A {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int d = sc.nextInt();
        int min = 101;
        int max = 0;
        PriorityQueue<Integer> minQueue = new PriorityQueue<>(n);
        PriorityQueue<Integer> maxQueue = new PriorityQueue<>(n, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            int temp = sc.nextInt();
            if (min > temp) min = temp;
            if (max < temp) max = temp;
            minQueue.add(temp);
            maxQueue.add(temp);
        }
        int countMin = 0;
        while (!maxQueue.isEmpty()) {
            int temp = maxQueue.poll();
            if (temp - min <= d) break;
            countMin++;
        }
        int countMax = 0;
        while (!minQueue.isEmpty()) {
            int temp = minQueue.poll();
            if (max - temp <= d) break;
            countMax++;
        }
        int ans = countMin > countMax ? countMax : countMin;
        System.out.println(ans);
    }

    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;
        }
    }
}
