Theorem (Riemann-Roch)

Let $V$ be a curve.

For any divisor $D$ and any canonical divisor $K_V$, $$ \begin{align*} l(D) - l(K_V - D) = 1 - g + \deg(D). \end{align*} $$ ($g$, $l$, $\deg$)

Setting $D = K_V$ (and noting $l(0) = 1$) gives $$ \begin{align*} \deg(K_V) = 2g - 2. \end{align*} $$

If $\deg(D) > \deg(K_V) = 2g - 2$, then $l(K_V-D) = 0$ so $$ \begin{align*} l(D) = 1 - g + \deg(D). \end{align*} $$