I know that the Cohen-Macaulay type has these two definitions:

 - Let $(R,\mathfrak{m},k)$ be a Cohen-Macaulay (noetherian) local ring and $M$ a finite $R$-module of depth $t$. The number $r(M) = \dim_k \mathrm{Ext}_R^t(k,M)$ is called the Cohen-Macaulay type of $M$.
 - Denote by $\beta_i(M)$ the Betti numbers in a minimal free resolution of $M$ ($M$ is an $R$-module as before). Then the Cohen-Macaulay type of $M$ is the last non zero Betti number, that is, $r(M) = \beta_s(M)$.

So I would ask how to prove the equivalence of these two definitions. There are some books in which I can find this proof?