Solution (source code)

= Solution

For a finite polygonal <CW complex> decomposition of a <compact> <surface>, with $V$ vertices, $E$ edges and $F$ faces after all identifications,
$$
\boxed{\chi=V-E+F.}
$$
This is the <Euler characteristic>, independent of the chosen subdivision. In a polygonal presentation, count <equivalence classes> of vertices and paired edges, rather than their number before gluing.