Valency is the last shell of atom. number of electrons in last shell are called valency electrons.
For example oxygen atomic number is 8. In first shell it has 2electrons. And shell it has 6electrons
I.e 2 electrons in S-orbital and 4 electrons in P-orbital
so it's valency is 6