The Proposition $(11.6)$ of Neukirch's Algebraic Number Theory states that if $\mathcal O$ is a dedekind domain with field of fractions $K$ and $X$ is a set of nonzero prime ideals of $\mathcal O$ with finite complement, there is a canonical exact sequence:
$\begin{eqnarray*} 1 \rightarrow U(\mathcal O) \rightarrow U(\mathcal O(X)) \rightarrow \bigoplus_{\mathfrak p\not\in X}K^*/U(\mathcal O_{\mathfrak p}) \rightarrow \mathscr C\ell(\mathcal O) \rightarrow \mathscr C\ell(\mathcal O(X)) \rightarrow 1, \end{eqnarray*}$
and that $K^*/U(\mathcal O_{\mathfrak p})\cong \mathbb Z$, for all prime $\mathfrak p\not\in X$.
Now let $\mathcal O_K$ be the ring of integers of $K$, let $S$ denote a finite set of prime ideals of $\mathcal O_K$, and let $X$ be the set of all prime ideals that do not belong to $S$. We put $\mathcal O_K^S = \mathcal O_K (X)$. The units of this ring are called the $S$-units.
(11.7) Corollary. For the group $K^S = (\mathcal O_K^S)*$ of $S$-units of $K$ there is an isomorphism $K^S\cong \mu(K) \times \mathbb Z^{\# S+r+s-1}$ where $r$ and $s$ are the number of real imersions and pairs of complex imersions of $K$.
The proof of Neukirch is as follows:
Proof: The torsion subgroup of $K^S$ is the group $\mu(K)$ of roots of unity in $K$. Since $\mathscr C\ell(\mathcal O)$ is finite, we obtain the following identities from the exact sequence above and from Dirichlet Units Theorem:
$rank(K^S)=rank(\mathcal O_K^*)+rank(\bigoplus_{\mathfrak p\in S}\mathbb Z)=\#S+r+s-1$.
I suppose the proof uses that result that relates exact sequences of $\mathbb Z$-modules and the ranks of these modules. But I only find:
$rank~U(\mathcal O)-rank~U(\mathcal O(X))+rank~\mathbb Z^{\# S}-rank~\mathscr C\ell(\mathcal O)+rank~\mathscr C\ell(\mathcal O(X))=0$.
Dirichlet Unit Theorem gives $rank~U(\mathcal O)=r+s-1$, but do I have some information about the ranks of the class groups?