  We evaluate the total integral from negative infinity to positive infinity of
all global solutions to the Painleve II equation on the real line. The method
is based on the interplay between one of the equations of the associated Lax
pair and the corresponding Riemann-Hilbert problem. In addition, we evaluate
the total integral of a function related to a special solution to the Painleve
V equation. As a corollary, we obtain short proofs of the computation of the
constant terms of the limiting gap probabilities in the edge and the bulk of
the Gaussian Orthogonal and Gaussian Symplectic Ensembles that were obtained
recently in [4] and [18]. We also evaluate the total integrals of certain
polynomials of the Painleve functions and their derivatives. These polynomials
are the densities of the first integrals of the modified Korteweg-de Vries
equation. We discuss the relations of the formulae we have obtained to the
classical trace formulae for the Dirac operator on the line.
