For calculating the valency of an atom, writing the electronic configuration of an atom in terms of orbital like s,p,d,f will be more accurate and will give greater insight.
Writing the electronic configuration in terms of K. L, M, N is only for main group elements ( s and p block elements) and it is restricted to only few elements in even s and p block elements.
For example the valency of carbon is 4. This can be explained as carbon is having 4 valence electrons and can share them. Hence the valency is 4. But the lead in the same group with 4 valence electron is having valency of 2. This cannot be explained on the basis of K, L, M, N configuration. If we write the electronic configuration in terms of orbital we will get the valency configuration of lead as
[Xe] 4f^14 5d^10 6s^2 6p^2. So if the two electrons from p orbital is only used the valency will be 2. This can be explained on the basis of orbital configuration only.