Given two circles. The first circle is inscribed in triangle $A B C$, the second touches side $A C$ and the extensions of sides $A B$ and $B C$. It is known that these circles touch each other, the product of their radii is 20, and the angle $B A C$ is $\arccos \frac{2}{3}$. Find the perimeter of triangle $A B C$.
Let the first (inscribed) circle of triangle $ABC$ touch the sides $AB$ and $BC$ at points $M$ and $P$, respectively, and the second (exscribed) circle touch the extensions of sides $AB$ and $BC$ at points $N$ and $Q$, respectively, and $K$ be the point of tangency of the circles (with $K$ on side $AC$). By the theorem on the equality of tangent segments drawn from a point to a circle,

\[
\begin{gathered}
B N = B Q, B M = B P, M N = P Q, A M = A K = A N = \frac{1}{2} M N \\
C P = C K = C Q = \frac{1}{2} P Q
\end{gathered}
\]

Therefore, $A B = B N - A N = B Q - C Q = B C$, i.e., triangle $ABC$ is isosceles. Its median $BK$ is also an altitude. Let $r$ and $R$ be the radii of the first and second circles, respectively. Then

\[
A C = M N = P Q = 2 \sqrt{\tau R} = 2 \sqrt{20} = 4 \sqrt{5}, A K = \frac{1}{2} \cdot A C = 2 \sqrt{5}
\]

From the right triangle $BAK$, we find that

\[
A B = \frac{A K}{\cos \angle B A C} = \frac{2 \sqrt{5}}{\frac{2}{3}} = 3 \sqrt{5}
\]

Therefore,

\[
A B + B C + A C = 3 \sqrt{5} + 3 \sqrt{5} + 4 \sqrt{5} = 10 \sqrt{5}
\]

## Answer

$10 \sqrt{5}$.