the valence electron is the ekectron in the outer most shell
we know
O2 has 16 electron altogether
now
O2- means it has gained 2 more electron
thus tota no of electron is 18
now
electron are distributed in shell as follow
2, in first shell
8 in second shell
8 in the third shell and so on
so filiing like this we have
8 electon in last shell that is the third shell