Computing sums with a Counter object