The number of electrons gained by a non-metallic element to achieve a stable electron configuration (octet rule) is equal to its valency. Valency is the combining capacity of an element, which is determined by the number of electrons it needs to gain, lose, or share to achieve a full outer electron shell.