import java.util.*;
public class Q1 {
	
	void solve()
	{
		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);
		int max = -1;
		
		for(int i=0;i<n;i++)
		{
			for(int j=i;j<n;j++)
			{
				if((a[j]-a[i]) <= d)
				{
					int l = j-i+1;
					if(l>max)
						max = l;
				}
			}
		}
		
		System.out.println(n-max);
		
	}
	
	public static void main(String[] args) {
		new Q1().solve();

	}

}
