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

public class A {

	
	public static void main(String[] agrs) throws IOException {
		FastScanner sc = new FastScanner();
//		int yo = sc.nextInt();
//		while(yo-->0) {	
//		}
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[] a = sc.readArray(n);
		Arrays.sort(a);
		int count = 0;
		
		for(int i = n-1; i >= 0; i--) {
			if(a[i]-a[0] > d) {
				count++;
			}
			else {
				break;
			}
		}
		System.out.println(count);
		
		
	} 
	
	
	
	static int gcd(int a, int b) {
		return a%b == 0 ? b : gcd(b,a%b);
	}
	
	static int mod = 1000000007;
	
	static long pow(int a, int b) {
		if(b == 0) {
			return 1;
		}
		if(b == 1) {
			return a;
		}
		if(b%2 == 0) {
		
			long ans = pow(a,b/2);
			return ans*ans;
		}
		else {
			long ans = pow(a,(b-1)/2);
			return a * ans * ans;
		}
		
	}
	
	static boolean[] sieve(int n) {
		
		boolean isPrime[] = new boolean[n+1];
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) continue;
			for(int j = 2*i; j <= n; j+=i) {
				isPrime[j] = true;
			}		
		}
		return isPrime;
	}
	

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	
	
//	For Input.txt and Output.txt
	
//	FileInputStream in = new FileInputStream("input.txt");
//	FileOutputStream out = new FileOutputStream("output.txt");
//	PrintWriter pw = new PrintWriter(out);
//	Scanner sc = new Scanner(in);
 
}
