A couple of notes. I've gone for \int_compare:nNn for performance
reasons over \int_compare:n, and I'd probably use the expansion of
\int_eval:n in the 'count' functions, so that it only requires two
expansions to get to the result rather than three.
--
Joseph Wright