Optimized counting