Extracting the total number can be done via the synthetic field %_total% (for track numbers in #/## format).
%_total%
#/##