You will need to customise the document library display and that is a quite involved script. When it calls the AJAX to load the view you will have to change the script that is called to count the children of any item that is a folder and return that value in the JSON. You will then have to modify the display to show this new data. Note that the display has several "views" (detailed, summary, gallery etc and you will need to modify each one to show the information. Its not hard, but it is "involved".