Calculate the number of valence electrons in an element using its electron configuration step by step.