The maximum number of electrons in the shell preceding the valence shell cannot exceed 8. This is known as the octet rule, which states that atoms tend to gain, lose, or share electrons in order to achieve a stable electron configuration with eight electrons in their outermost shell (except for hydrogen and helium, which can achieve stability with two electrons). This stability is similar to the electron configuration of the noble gases, which have full valence shells.