The maximum number of electrons that can occupy a specific energy level can be found using the following formula:
Electron Capacity =
The variable n represents the Principal Quantum Number, the number of the energy level in question.
(Principal Quantum Number) = 1,2,3.4...
Shell Letter = K,L,M,N,....
Electron Capacity = 2,8,18,32,...respectively
Keep in mind that an energy level need not be completely filled before electrons begin to fill the next level. You should always use the Periodic Table of Elements to check an element's electron configuration table if you need to know exactly how many electrons are in each level.
and the best way is to memorize it...