We show, starting from simple differential geometric example, that the partition function of a twisted N = 4 Yang-Mills theory on certain manifold X is localized on instanton moduli space. Moreover, it equals to the Euler characteristic of this moduli space.