Parse a compound count (number of compounds).

def parse_compound_count(s):
    """Parse a compound count (number of compounds)."""
    m = re.match(r'^\((.*)\)$', s)
    if m:
        s = m.group(1)

    for count_type in (int, Decimal, affine.Expression):
        try:
            return count_type(s)
        except:
            pass

    raise ValueError('Unable to parse compound count: {}'.format(s))