Do note that by counting the area in 2 ways, the first altitude is $x = \frac{ab}{c}$. By similar triangles, the common ratio is $\rho = \frac{a}{c}$ for each height, so by the geometric series formula, we have 
\begin{align}     6p=\frac{x}{1-\rho} = \frac{ab}{c-a}. \end{align}
Writing $p=a+b+c$ and clearing denominators, we get \[13a=6p .\]Thus $p=13q$, $a=6q$, and $b+c=7q$, i.e. $c=7q-b$. Plugging these into $(1)$, we get $78q(q-b)=6bq$, i.e., $14b=13q$. Thus $q=14r$ and $p=182r$, $b=13r$, $a=84r$, $c=85r$. Taking $r=1$ (since $a,b,c$ are relatively prime) we get $p=\boxed{182}$.
Triangle $ABC_0$ has a right angle at $C_0$. Its side lengths are pairwise relatively prime positive integers, and its perimeter is $p$. Let $C_1$ be the foot of the altitude to $\overline{AB}$, and for $n \geq 2$, let $C_n$ be the foot of the altitude to $\overline{C_{n-2}B}$ in $\triangle C_{n-2}C_{n-1}B$. The sum $\sum_{n=2}^\infty C_{n-2}C_{n-1} = 6p$. Find $p$.