how do we know how many electrons are in each sublevel?
The s sublevel has just one orbital, so can contain 2 electrons max. The p sublevel has 3 orbitals, so can contain 6 electrons max. The d sublevel has 5 orbitals, so can contain 10 electrons max. And the 4 sublevel has 7 orbitals, so can contain 14 electrons max.