The number of master integrals as Euler characteristic