Perform the following steps:

Open a FrameMaker book file

From the menu choose
FINALYSER>Book Services>Last Page Number
Confirm the opening window with
OK
In the book, open a file and go to the master page

Via
Special>Variables insert the generated user variable "SQUIDDS_Number_Of_Pages" in the header or footer

The total number of pages is now displayed on the body page.

Via
Import Formats>Variable Definitions the variable can be imported into all other documents of the book.