Technically it’s possible with script, but your website would be too slow and useless because literally the script would have to walk through hundreds of pages to do the categorical counting.
Even the API doesn’t offer item filter-queries or an item count function- even if it could be accessed by client side script ( it cannot ).
Your best option is probably to pay for a service that syncs your CMS to an external data store like AirTable, and then build a view there that you can query.