A new characterization of Cohen-Macaulay rings