def bit_count(num: int):
    """Counts the number of bits with value 1."""
    try:
        return num.bit_count()  # Python 3.10 (~6 times faster)
    except AttributeError:
        return bin(num).count("1")