  We count the finitely generated subgroups of the modular group
$\textsf{PSL}(2,\mathbb{Z})$. More precisely: each such subgroup $H$ can be
represented by its Stallings graph $\Gamma(H)$, we consider the number of
vertices of $\Gamma(H)$ to be the size of $H$ and we count the subgroups of
size $n$. Since an index $n$ subgroup has size $n$, our results generalize the
known results on the enumeration of the finite index subgroups of
$\textsf{PSL}(2,\mathbb{Z})$. We give asymptotic equivalents for the number of
finitely generated subgroups of $\textsf{PSL}(2,\mathbb{Z})$, as well as of the
number of finite index subgroups, free subgroups and free finite index
subgroups. We also give the expected value of the isomorphism type of a size
$n$ subgroup and prove a large deviations statement concerning this value.
Similar results are proved for finite index and for free subgroups. Finally, we
show how to efficiently generate uniformly at random a size $n$ subgroup (resp.
finite index subgroup, free subgroup) of $\textsf{PSL}(2,\mathbb{Z})$.
