import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.io.*;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		// Scanner read = new Scanner(new FileInputStream(new
		// File("input.txt")));
		// PrintWriter out = new PrintWriter(new File("output.txt"));
		Scanner read = new Scanner(System.in);
		int n = read.nextInt(), d = read.nextInt(), arr[] = new int[n + 1], c = 0, max = -1 ;
		for (int i = 0; i < n; i++)
			arr[i] = read.nextInt();
		for (int i = 0; i < n; i++) {
			c = 0;
			for (int j = i+1; j < n; j++) {
				if (Math.abs(arr[i] - arr[j]) <= d)
					c++;
			}
			max = Math.max(max, c);
		}
		System.out.println(n - max - 1);
	}
}
