We perform a quantitative analysis of the solar composition problem by using a statistical approach that allows us to combine the information provided by helioseimic and solar neutrino data in an effective way. We include in our analysis the helioseismic determinations of the surface helium abundance and of the depth of the convective envelope, the measurements of the $^7{rm Be}$ and $^8{rm B}$ neutrino fluxes, the sound speed profile inferred from helioseismic frequencies. We provide all the ingredients to describe how these quantities depend on the solar surface composition and to evaluate the (correlated) uncertainties in solar model predictions. We include errors sources that are not traditionally considered such as those from inversion of helioseismic data. We, then, apply the proposed approach to infer the chemical composition of the Sun. We show that the opacity profile of the Sun is well constrained by the solar observational properties. In the context of a two parameter analysis in which elements are grouped as volatiles (i.e. C, N, O and Ne) and refractories (i.e Mg, Si, S, Fe), the optimal composition is found by increasing the the abundance of volatiles by $left( 45pm 4right)%$ and that of refractories by $left( 19pm 3right)%$ with respect to the values provided by AGSS09. This corresponds to the abundances $varepsilon_{rm O}=8.85pm 0.01$ and $varepsilon_{rm Fe}=7.52pm0.01$. As an additional result of our analysis, we show that the observational data prefer values for the input parameters of the standard solar models (radiative opacities, gravitational settling rate, the astrophysical factors $S_{34}$ and $S_{17}$) that differ at the $sim 1sigma$ level from those presently adopted.