So whenever you need to find valence electron look at Group Number and you can find it, Example barium it’s on group 2 it’s means it have 2 valence electrons.
let’s look for nitrogen group 5A that means it have 5 valence eletrons.
hope it’s help.
Let me know if you have any chemistry related questions