We need to identify which of the given metals react with both oxygen (O$_2$) and nitrogen (N$_2$) from the air upon burning.
Alkali Metals (Group 1):
- Li (Lithium): Lithium is unique in Group 1 as it reacts directly with nitrogen to form lithium nitride (Li$_3$N), in addition to forming lithium oxide (Li$_2$O) with oxygen. So, Li forms both.
- Na (Sodium): Primarily forms sodium peroxide (Na$_2$O$_2$) and does not react with nitrogen under these conditions.
- K (Potassium): Primarily forms potassium superoxide (KO$_2$) and does not react with nitrogen.
Alkaline Earth Metals (Group 2):
- All alkaline earth metals burn in air to form both oxides (MO) and nitrides (M$_3$N$_2$). This is a characteristic property of Group 2 elements due to their high reactivity.
- Be (Beryllium): Forms BeO and Be$_3$N$_2$.
- Mg (Magnesium): Forms MgO and Mg$_3$N$_2$.
- Sr (Strontium): Forms SrO and Sr$_3$N$_2$.
- Ba (Barium): Forms BaO and Ba$_3$N$_2$.
Counting the metals from the given list that form both oxides and nitrides:
Li, Be, Mg, Ba, Sr.
There are a total of 5 such metals.