3. A regular triangular prism with base edge $n$ and lateral edge $m$ (where $m$ and $n$ are natural numbers) is first painted and then divided into similar prisms with base edge and lateral edge lengths of 1 (as shown in the diagram). Calculate how many prisms will remain with all faces unpainted.
![](https://cdn.mathpix.com/cropped/2024_06_05_df4cd6b4472bb43b0444g-11.jpg?height=254&width=704&top_left_y=767&top_left_x=762)
Solution. In a triangle with side $n$, there are $n^{2}$ small triangles. Indeed, starting from the base to the vertex, there are

$$
n+(n-1)+(n-2)+\ldots+3+2+1=\frac{n(n+1)}{2}
$$

triangles turned with the vertex inward and

$$
(n-1)+(n-2)+\ldots+3+2+1=\frac{n(n-1)}{2}
$$

triangles turned with the vertex outward. Therefore, the prism is divided into

$$
p_{v k}=m \cdot\left(\frac{n(n-1)}{2}+\frac{n(n+1)}{2}\right)=m \cdot n^{2}
$$

small prisms.

Of all the small prisms, at least one side will be painted for those located on the two bases and on the lateral sides of the prism, i.e.,

$$
\begin{aligned}
p_{o b} & =2 n^{2}+(m-2) \cdot n+(m-2)(n-1)+(m-2)(n-2) \\
& =2 n^{2}+(m-2)(3 n-3)
\end{aligned}
$$

Therefore, the number $p$ of unpainted prisms is

$$
p=p_{v k}-p_{o b}=(m-2)\left(n^{2}-3 n+3\right)
$$