Optimised number of depleted piles counter