///package com.company;

import java.util.*;

public class Main {
    public enum Size {
        SMALL, MEDIUM,
        LARGE, EXTRA_LARGE
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        int n = in.nextInt();
        int k = in.nextInt();

        int[] a = new int[n];

        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        Arrays.sort(a);
        int ans = 110;
        for(int i = 0; i < n; i++) {
            int cnt = i;
            for(int j = 0; j < n; j++) {
                if(a[j] > a[i] + k) {
                    cnt++;
                }
            }
            ans = Math.min(ans, cnt);
        }

        System.out.print(ans);
    }
}