import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt(),y=sc.nextInt(),z,r=0;
        Vector<Integer>vec=new Vector<>();
        for(int i=0;i<x;i++){
            z=sc.nextInt();
            vec.add(z);
        }
        Collections.sort(vec);
        for(int i=0;i<x;i++){
            for(int c=0;c<x;c++){
                if(Math.abs(vec.get(i)-vec.get(c))<=y){
                    if(Math.abs(c-i)>r)
                        r=Math.abs(c-i);
                }
            }
        }
        System.out.println(x-r-1);
    }



    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}