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


Since $\frac{2}{3}=\frac{2 k}{3 k}=\frac{q+1}{p} \Rightarrow \frac{q}{p}=\frac{2 k-1}{3 k} \in\left(0, \frac{5}{8}\right) \Rightarrow 1 \leqslant k \leqslant 7$, the corresponding $\frac{q}{p}=\frac{1}{3}, \frac{3}{6}, \frac{5}{9}, \frac{7}{12}, \frac{9}{15}, \frac{11}{18}, \frac{13}{21}$.

Removing the fractions that are not in simplest form $\frac{3}{6}, \frac{9}{15}, f(x)=\frac{2}{3}$ has 5 roots in $S$.