12. Let the lengths of the two legs of a right triangle be $a$ and $b$, and the length of the hypotenuse be $c$. If $a$, $b$, and $c$ are all integers, and $c=\frac{1}{3} a b-(a+b)$, find the number of right triangles that satisfy the condition.
12. By the Pythagorean theorem, we have
$$
c^{2}=a^{2}+b^{2} \text {. }
$$

Also, $c=\frac{1}{3} a b-(a+b)$, substituting into equation (1) gives
$$
\begin{array}{l}
a^{2}+b^{2} \\
=\frac{1}{9}(a b)^{2}-\frac{2}{3} a b(a+b)+a^{2}+2 a b+b^{2} .
\end{array}
$$

Simplifying, we get
$$
\begin{array}{l}
a b-6(a+b)+18=0 \\
\Rightarrow(a-6)(b-6)=18 .
\end{array}
$$

Since $a, b$ are both positive integers, without loss of generality, let $a<b$. Then
$$
\left\{\begin{array} { l } 
{ a - 6 = 1 , } \\
{ b - 6 = 1 8 }
\end{array} \text { or } \left\{\begin{array} { l } 
{ a - 6 = 2 , } \\
{ b - 6 = 9 }
\end{array} \text { or } \left\{\begin{array}{l}
a-6=3, \\
b-6=6 .
\end{array}\right.\right.\right.
$$

Solving, we get $(a, b, c)$
$$
=(7,24,25),(8,15,17),(9,12,15) \text {. }
$$

Therefore, there are three right triangles that satisfy the conditions.