//940A
import java.io.*;
import java.util.*;
public class acm{
	public static void main(String args[]) throws IOException{
		BufferedReader gi = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter go = new PrintWriter(System.out);
		String ind[] = gi.readLine().split(" ");
		String ss[] = gi.readLine().split(" ");
		int n = Integer.parseInt(ind[0]), d = Integer.parseInt(ind[1]);
		int L[] = new int[101];
		for (String s: ss){
			L[Integer.parseInt(s)]++;
		}
		int a = 0;
		for (int k = 0; d<101; k++){
			a = Math.max(a, functs.sum(L,k,d));
			d++;
		}
		go.println(functs.sum(L,0,100) - a);
		go.close();
	}
}

class functs{
	public static int sum(int L[], int start, int end){
		int res = 0;
		for (int k = start; k<=end; k++){res+=L[k];}
		return res;
	}
}
