3. Divide a rectangle with side lengths of positive integers $m, n$ into several squares with side lengths of positive integers, with each square's sides parallel to the corresponding sides of the rectangle. Try to find the minimum value of the sum of the side lengths of these squares.
Let the required minimum value be $f(m, n)$. It can be proven that: $f(m, n) = m + n - (m, n)$.
Here, $(m, n)$ represents the greatest common divisor of $m$ and $n$. Without loss of generality, assume $m \geqslant n$.
(1) By induction on $m$, we can prove that there exists a way to divide the rectangle such that the sum of the side lengths of the resulting squares is exactly $m + n - (m, n)$. When $m = 1$, $ABCD$ is a square, and the proposition is clearly true; assume that when $m \leqslant k (k \geqslant 1)$, the proposition holds. When $m = k + 1$, if $n = k + 1$, $ABCD$ is a square, and the proposition is clearly true; if $n < k + 1$, then the rectangle can be divided into a square with side length $a_1$ and a smaller rectangle with side lengths $m - a_1$ and $n$.
If $a_1 < n$, then the sum of the side lengths of the resulting squares is greater than $m + n - (m, n)$;
If $a_1 = n$, then the rectangle with side lengths $m - n$ and $n$ can be divided into squares with side lengths $a_2, a_3, \cdots, a_p$ as required. By the induction hypothesis, $a_2 + a_3 + \cdots + a_p \geqslant m - n + n - (m - n, n) = m - (m, n)$, 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)$. In summary, the minimum value of the sum of the side lengths of the squares is $f(m, n) = m + n - (m, n)$.