The following will make the total number of pages of the entire document equal to where the section begins (excluding the cover and TOC pages).
1. In the master template add the page number to the footer on the page following the section break (must be in the format; "page number" of "total pages").
2. Once added, highlight the "number of pages" number in the footer.
3. Right click on the "number of pages" number and click "Toggle Field Codes" to enter the field code mode.
4. Make the field code look like the screenshot below. X being the number of pages you want subtracted (cover and TOC pages).
5. Save the document/template.