The moduli space of flat SU(2) connections on a punctured surface, having prescribed holonomy around the punctures, is a compact smooth manifold if the prescription is generic. This paper gives a direct, elementary proof that the trace of the holonomy around a certain loop determines a Bott-Morse function on the moduli space which is perfect, meaning that the Morse inequalities are equalities. This leads to an attractive recursion for the Betti numbers of the moduli space, which agrees with the Harder-Narasimhan formula in the case of one puncture with holonomy -1.