  The calculation of the partition function for N M5-branes is addressed for
the case in which the worldvolume wraps a manifold $T^2\times M_4$, where $M_4$
is simply connected and Kaehler. This is done in a compactification of M-theory
which induces the Vafa-Witten theory on $M_4$ in the limit of vanishing torus
volume. The results follow from the equivalence of the BPS spectrum counting in
the complementary limit of vanishing $M_4$ volumes and from a classification of
the the moduli space of quantum vacua of the supersymmetric twisted theory in
terms of associated spectral covers. This reduces the problem of the moduli
counting to algebraic equations.
