A natural refinement of the Euler characteristic