We develop a formalism for computing sums over random surfaces which arise in all problems containing gauge invariance (like QCD, three-dimensional Ising model etc.). These sums are reduced to the exactly solvable quantum theory of the two-dimensional Liouville lagrangian. At D = 26 the string dynamics is that of harmonic oscillators as was predicted earlier by dual theorists, otherwise it is described by the nonlinear integrable theory.