Rule to determine the total number of elements in a period
The total number of elements formed due to their last electron entering the $n$-th shell will be equal to the total number of electrons that shell can fill. For each electron added or removed (along with a proton), you'll get a new element, since a unique element is itself defined by a unique count of protons. 

Thus, this problem is reduced to finding the total number of electrons in $n$-th shell. And, simply enough, the total number of electrons in $n$-th shell = number of orbitals in $n$-th shell $\times$ number of electrons each orbital can hold.

For example, for $n=3$, we have $\ell=0,1,2$. Thus, the number of orbitals here is $=1+3+5=9$ (recall that s-subshell has 1 orbital, p-orbital has 3 orbitals, and so on[1]). Since $s=\pm 1/2$, each orbital can fit two electrons, thus total count of electrons is $=2\times9=18$, which is also the total number of elements in the third shell.

In your question, the only change is that each orbital can now hold three electrons (by some phenomenon we don't know yet!) So, in the final step, just multiply the total number of orbitals by three instead!



To calculate the number of elements in a particular period, you need to note the individual subshells that belong to that period, and then sum up the number of the elements from those subshells. 

In my solution above, I have shown how to get the total number of elements formed due to their last electron entering the $n$-th shell, which is not equivalent to the number of elements in $n$-th period.

For example, in the fourth period of the periodic table, you have the $\ce{4s, 3d}$, and the $\ce{4p}$ subshells. This is the calculation that your solution manual has shown in the second row.



[1]: In general, the total number of orbitals $k$ in shell $n$ is:

$$k = \sum_{\ell=0}^{n-1}(2\ell+1)$$

since: a) each $m$ value stands for a unique orbital b) $-\ell\leq m\leq\ell$, thus $m$ has a total of $2\ell+1$ values for a particular $\ell$ value