### Page numbering "<n> of <m>"

Finding the page number of the last page of a document, from within the document, is somewhat tricky. The lastpage package is therefore supplied to make life easy for us all; it defines a label `LastPage` whose number is right (after sufficiently many passes through LaTeX, of course).

The documentation of the fancyhdr package spells out exactly how one might actually use this information to produce page numbering as suggested in the question.

`fancyhdr documentation`
  macros/latex/contrib/supported/fancyhdr.tar.gz
`lastpage.sty`
  macros/latex/contrib/other/lastpage.tar.gz