import math


def trits_bise_bitcount(items, bits):
    """
    Compute the number of bits needed for trit-based encoding.
    """

    assert items > 0 and bits >= 0
    #return math.ceil((8.0 + 5.0*bits) * items / 5.0)
    return math.ceil(8.0*items / 5.0 + bits*items)