This problem is closely connected with number-theoretic model for spin chains. In this model, to a finite chain of spins each of which can be directed upwards $(\uparrow)$ or downwards $(\downarrow)$, a product of
the matrices
$$
  A=\begin{pmatrix}
        1 & 0\\
        1 & 1
    \end{pmatrix},\quad
  B=\begin{pmatrix}
        1 & 1\\
        0 & 1
    \end{pmatrix}
$$
is assigned, according to the rule
$\uparrow=A$, $\downarrow=B$. For example,
$$
  \uparrow\uparrow\uparrow\downarrow\downarrow\uparrow\uparrow\uparrow\uparrow=
  \uparrow^3\downarrow^2\uparrow^4=A^3B^2A^4.
$$
The energy of a given configuration is
$$
  E(\uparrow^{a_1}\downarrow^{a_2}\uparrow^{a_3}\ldots)=
   \log\left(\mathrm{Tr}\,(A^{a_1}B^{a_2}A^{a_3}\ldots)\right).
$$
Let $G$ be the free multiplicative monoid generated by the matrices $A$ and $B$.
From a physical viewpoint, the asymptotic behaviour of the number of configurations
$$
  \Phi(N)=\bigl|\bigl\{C\in G: \mathrm{Tr}\,C=N \bigr\}\bigr|\qquad(N\ge 3)
$$
with a given energy, and the number of configurations in which the energy does not exceed a given
quantity,
$$
  \Psi(N)=\big |\big\{C\in G: 3\le\mathrm{Tr}\,C\leqslant N \big\}\big |=
  \sum_{3\le n\leqslant N}\Phi(n).
$$
It is known, that
$$ \Psi(N)=N^2(c_1\log N+c_0)+{O}(N^{3/2}\log^4N),
$$
where 
$$
  c_1=\frac{1}{\zeta(2)},\quad  c_0=
  \frac{1}{\zeta(2)}\left(\gamma-\frac{3}{2}-\frac{\zeta'(2)}
  {\zeta(2)}\right).
$$
And this result is a special case of a more general result concerning the Gauss-Kuz’min statistics for spin chains and Gauss-Kuz’min statistics for the quadratic irrationals. For more details see the paper [Spin chains and Arnold's problem on the Gauss-Kuz'min statistics for quadratic irrationals.][1].


  [1]: https://iopscience.iop.org/article/10.1070/SM2013v204n05ABEH004319