We prove a commutative algebra result which has consequences for congruences between automorphic forms modulo prime powers. If C denotes the congruence module for a fixed automorphic Hecke eigenform pi(0), we prove an exact relation between the p-adic valuation of the order of C and the sum of the exponents of p-power congruences between the Hecke eigenvalues of pi(0) and other automorphic forms. We apply this result to several situations including the congruences described by Mazur's Eisenstein ideal.