Dear Student,
Maximum number of electrons that a shell (K, L, M and N.... ) can hold is given by is given by 2n2 rule where n is the number of shell.
For K shell, n= 1 212 = 2, means K shell can accommodate 2 electrons
For L shell, n = 2, 2 22 = 8, means L shell can accommodate 8 electrons.
For M shell, n = 3, 2 x 32 = 18, means M shell can accommodate 18 electrons.
For N shell, n = 4, 242 = 32, means N shell can accommodate 32 electrons.
Regards