Precomputing counts