Let $X$ be a compact Riemann surface of genus $g\geq 2$. By the Riemann-Roch theorem, $X$ is a branched cover of the sphere, branched over finitely many branched values. What is the smallest number of such values, for general $X$ of genus $g$?

Since moduli space has complex dimension $3g-3$, and branched covers branched over $B$ points are contained in the union of countably many varieties of dimension at most $B-3$, for general $X$ we need at least $3g$ branched values.

Riemann-Roch shows that there is a holomorphic $X\to\hat{\mathbb{C}}$ of degree $g+1$ having a single pole, of degree $g+1$. By Riemann-Hurwitz, this function has $4g$ critical points, of which $g$ are over infinity. So in total there are at most $3g+1$ critical values. So my question becomes:

**Question.** Let $X$ be a compact Riemann surface of genus $g\geq 2$. Is there a holomorphic function $f\colon X\to \hat{\mathbb{C}}$ which has at most $3g$ critical values?

It is plausible that the answer is positive, but in either case the answer is surely known. Does anyone know a reference?

I have been told that Brill-Noether theory shows the existence of a meromorphic function of degree $\lfloor(g+3)/2\rfloor$ on $X$. For even $g$, applying Riemann-Hurwitz then shows that there are $3g$ critical points for this function. That answers the question in the positive for even $g$. But for odd $g$, we get the same number $3g+1$ as via Riemann-Roch.