Quantum chemical definition and calculation of valence