Three. (50 points) Divide a rectangle with side lengths of positive integers $m$ and $n$ into several squares with side lengths of positive integers, where each square's sides are parallel to the corresponding sides of the rectangle. Find the minimum value of the sum of the side lengths of these squares.

---

Please note that the translation retains the original format, including the points allocation and the structure of the problem statement.
Three, let the minimum value sought be $f(m, n)$, it can be proven that
$$
f(m, n)=m+n-(m, n).
$$

where $(m, n)$ represents the greatest common divisor of $m$ and $n$.
In fact, without loss of generality, assume $m \geqslant n$.
(1) Induction on $m$. It can be proven that there exists a valid partition such that the sum of the side lengths of the resulting squares is exactly $m+n-(m, n)$.
When $m=1$, the proposition is clearly true.
Assume that when $m \leqslant k$, the conclusion holds $(k \geqslant 1)$. When $m=k+1$, if $n=k+1$, then the proposition is clearly true. If $n < m$, then the sum of the side lengths of the squares is $m+n-(m, n)$.
If $a_{1}=n$, then a rectangle with side lengths $m-n$ and $n$ can be divided into squares with side lengths $a_{2}, \cdots, a_{p}$ as required by the problem. By the induction hypothesis,
$$
\begin{array}{l}
a_{2}+\cdots+a_{p} \geqslant m-n+n-(m-n, n) \\
=m-(m, n).
\end{array}
$$

Thus, $a_{1}+a_{2}+\cdots+a_{p} \geqslant m+n-(m, n)$.
Therefore, when $m=k+1$,
$$
f(m, n) \geqslant m+n-(m, n).
$$

Furthermore, by (1), we have $f(m, n)=(m+n)-(m, n)$.
(Supplied by Yu Qiao)