I have a problem like this
"Let $R$ be a Cohen-Macaulay local ring, $\dim R=d$. Given that every maximal Cohen-Macaulay $R$-module is free, prove that $R$ is a regular local ring."
My lecturer gave me a hint to use the Auslander-Buchsbaum theorem: $\operatorname{depth} R=\operatorname{depth}_R M +\operatorname{pd}_R M$ if $\operatorname{pd}_R M<\infty$. However, I am still stuck since I want to prove that $\operatorname{pd}_R R/\mathfrak{m}<\infty$, but I don't know how the hint works at all?
Thank you for your help