The Valence Formula and Its Applications