Solution (source code)

= Solution

The <genus formula for a modular curve> is
$$
g=1+\frac\mu{12}-\frac{e_2}{4}-\frac{e_3}{3}-\frac c2,
$$
where $\mu=[PSL_2(\mathbb Z):\overline\Gamma]$, $e_2,e_3$ count elliptic orbits of orders two and three, and $c$ is the number of cusps.

For $\Gamma_0(3)$,
$$
\mu=3\left(1+\frac13\right)=4.
$$
There are two cusps, represented by infinity and zero. The congruence $x^2+1\equiv0\pmod3$ has no solution, so there is no elliptic orbit of order two. The congruence $x^2+x+1\equiv0\pmod3$ has the single solution $x=1$, giving one elliptic orbit of order three. Therefore
$$
g(X_0(3))=1+\frac4{12}-0-\frac13-\frac22=0,
$$
which is the <Modular curve X0 3> calculation.