import java.util.*;
import java.lang.*;

public class hello {
	public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	int n = in.nextInt();
	int d = in.nextInt();
	int[] mas = new int[100];
	for (int i=0; i<n; i++) {
		mas[i]=in.nextInt();
	}
	in.close();
	int t=n;
	if (n==1) {System.out.println(0); System.exit(0);}
	int s=1;
	int k=0;
	if (d==0) {
		for (int i=0; i<n-1; i++) {
			for (int j=i+1; j<n; j++) {
				if (mas[i]==mas[j])s++;
			}
			if (s>k)k=s;
			s=1;
		}
		System.out.println(n-k);
		System.exit(0);
	}
	else {
	for (int i=0; i<n-1; i++) {
		int b;
		for (int j=i+1; j<n; j++) {
			if (Math.abs(mas[j]-mas[i])==d) {
				b=j-i-1;
				if (n-b-2<t)t-=(b+2);
			}
			b=0;
		}
	}
	System.out.println(t);
	}
	}
}
