use the shared bit-counting function