6. Let $S$ be the set of all rational numbers in the interval $\left(0, \frac{5}{8}\right)$, for the fraction $\frac{q}{p} \in S, (p, q)=1$, define the function $f\left(\frac{q}{p}\right)=\frac{q+1}{p}$. Then the number of roots of $f(x)=\frac{2}{3}$ in the set $S$ is $\qquad$
6.5.

Since $f(x)=\frac{2}{3}$, let $q=2 m-1, p=3 m\left(m \in \mathbf{Z}_{+}\right)$.
Then, $0<\frac{2 m-1}{3 m}<\frac{5}{8} \Rightarrow \frac{1}{2}<m<8$. Upon verification, the number of roots of the equation is 5.