how do you know how many electrons are in the outermost shell?
Valence electrons can be found by determining the electronic configurations of elements. Thereafter the number of electrons in the outermost shell gives the total number of valence electrons in that element.