  A generating function of the number of homomorphisms from the fundamental
group of a compact oriented or non-orientable surface without boundary into a
finite group is obtained in terms of an integral over a real group algebra. We
calculate the number of homomorphisms using the decomposition of the group
algebra into irreducible factors. This gives a new proof of the classical
formulas of Frobenius, Schur, and Mednykh.
