Suppose we are given a continued fraction $$\frac{p}{q}=a_{1}+\frac{1}{a_{2}+\frac{1}{a_{3}+\frac{1}{a_{4}+\cdots}}}$$
I am trying to find an expression, possibly asymptotic, for the sum of the $a_i$'s for a given $\frac{p}{q}$.
I understand that this is related to the Stern-Brocot tree. In particular, our problem is equivalent to finding on which row does the fraction $\frac{p}{q}$ first appear in the Stern-Brocot tree.
Are there any results to this problem?