import java.util.*;
public class q466a {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i< n;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		boolean dist[][]= new boolean[n][n];
		int count[] = new int [n];
		for(int i = 0; i < n;i++) {
			count[i] = 0;
			dist[i][i] = true;
			for(int j = 0; j < n; j++) {
//				System.out.println("i = "+i+",j = "+j);
//				System.out.println("a[i] = "+a[i]+",a[j] ="+a[j]);
//				System.out.println(Math.abs(a[i]-a[j]));
				if(Math.abs(a[i]-a[j]) <= d) {
//					System.out.println("i = "+i+",j = "+j);
//					System.out.println("a[i] = "+a[i]+",a[j] ="+a[j]);
//					System.out.println(Math.abs(a[i]-a[j]));
					dist[i][j] = true;
					dist[j][i] = true;
				}
				else {
					count[i]++;
				}
			}
		}
		int remove = 0;
		for(int i = 0, j = n-1; i < j; ) {
//			System.out.println("i = "+i+",j = "+j);
//			System.out.println("a[i] = "+a[i]+",a[j] ="+a[j]);
//			System.out.println("dist[i][j] = "+dist[i][j]);
//			System.out.println(count[i]);
//			System.out.println(count[j]);;
			if(dist[i][j]) {
//				i++;
//				continue;
				break;
			}
			if(count[i] <= count[j]) {
				if(delete(i,j-1, a,dist,count)) {
					remove++;
					break;
				}
				else {
					remove++;
				}
				j--;
			}
			else {
				if(delete(i+1,j, a,dist,count)) {
					remove++;
					break;
				}
				else {
					remove++;
				}
				i++;
			}
//			System.out.println("i = "+i+",j = "+j);
		}
		System.out.println(remove);
	}

	private static boolean delete(int i, int j, int[] a, boolean dist[][], int count[]) {
		int n = a.length;
		boolean flag = true;
		for(; i <= j; i++) {
			if(!dist[i][j]) {
				flag = false;
			}
		}
		return flag;
	}
	
}
