check the picture below
so, that's the height of the pyramid, or "h"
recall [tex]\bf \textit{volume of a pyramid}\\\\
V=\cfrac{1}{3}Bh\qquad
\begin{cases}
B=\textit{base area}\\
h=height\\
------\\
B=40\cdot 40\\
h=\sqrt{25^2-20^2}
\end{cases}\implies V=\cfrac{1}{3}\cdot 40\cdot 40\cdot \sqrt{25^2-20^2}[/tex]