def solve():
    N, d = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort()

    if L[-1] - L[0] <= d:
        print(0)
        return

    for n in range(1, N):
        for l in range(n):
            LC = L[l:-(n-l)]
            if LC[-1] - LC[0] <= d:
                print(n)
                return


if __name__ == "__main__":
    solve()


