Answer
a) Two.
b) One.
Work Step by Step
$$\color{blue}{\bf [a]}$$
In a lithium atom, which has a total of three electrons, two are found in the $1s$ shell, and the third electron is located in the $2s$ shell. The third electron in the $2s$ shell possesses quantum numbers $n = 2$, $l = 0$, $m_l = 0$, and $m_s$ can be either $+\frac{1}{2}$ or $-\frac{1}{2}$. The possible spin states of this electron mean that lithium behaves similarly to hydrogen, as these spin states allow for two distinct energy states due to their magnetic moments. Consequently, we can expect to observe $\underline{\color{red}{\text{two spectral lines}}}$ from lithium corresponding to these two states.
$$\left(2,0,0,+\frac{1}{2}\right),\;\;\;\left(2,0,0,-\frac{1}{2}\right)$$
$$\color{blue}{\bf [b]}$$
For beryllium, which contains four electrons, two fill the $1s$ shell and the other two occupy the $2s$ shell. Since the paired electrons in both the $1s$ and $2s$ shells have their magnetic moments aligned oppositely, they cancel each other out. This results in beryllium having no overall magnetic moment. Thus, in a Stern-Gerlach experiment, where separation depends on the magnetic properties of the atom, beryllium would not be deflected, leading to the observation of only $\underline{\color{red}{\text{one spectral line}}}$. This absence of deflection demonstrates that beryllium has no net magnetic moment.