import java.util.Scanner;

// Codeforces.java - (insert one line description here)
/**
 * 466 Div 2 Q1
 * Fafa and fifa
 */
public class CodeForces25
{
    public static int maxSubSeq(final int[] arr, final int d)
    {
        int maxNos = -1, midPos = -1;
        int minRemovals = Integer.MAX_VALUE;
        for (int i = 1; i < 101; i++)
        {
            if (arr[i] == 1)
            {
                int curMAx = 0;
                int start = i, end = i + d;
                if (start < 1)
                {
                    start = 1;
                }
                if (end > 100)
                {
                    end = 100;
                }
                while (start <= end)
                {
                    if (arr[start] == 1)
                    {
                        curMAx += 1;
                    }
                    start++;
                }
                if (curMAx >= maxNos)
                {
                    final int curRemovals = countRemovals(arr, midPos, d);
                    if (curRemovals < minRemovals)
                    {
                        maxNos = curMAx;
                        midPos = i;
                        minRemovals = curRemovals;
                    }

                }

            }

        }
        return minRemovals;
    }

    public static int countRemovals(final int[] arr, final int midPos, final int d)
    {
        int start = midPos, end = midPos + d, count = 0;
        if (start < 1)
        {
            start = 1;
        }
        if (end > 100)
        {
            end = 100;
        }
        for (int i = 1; i <= 100; i++)
        {
            if(arr[i] == 1 && (i < start || i > end)){
                count++;
            }
        }
        return count;

    }
    public static void main(final String[] args)
    {
        final int[] arr = new int[101];
        for (int i = 0; i <= 100; i++)
        {
            arr[i] = 0;
        }
        final Scanner in = new Scanner(System.in);
        final int n = in.nextInt();
        final int d = in.nextInt();
        for (int i = 0; i < n; i++)
        {
            arr[in.nextInt()] = 1;
        }

        final int minRemovals = maxSubSeq(arr, d);
        System.out.println(minRemovals);

    }

}
