Abstract: In his work on modularity theorems, Wiles proved a numerical criterion for a map of rings R->T to be an isomorphism of complete intersections. He used this to show that certain deformation rings and Hecke algebras associated to a mod p Galois representation at non-minimal level were isomorphic and complete intersections, provided the same was true at minimal level. In addition to proving modularity theorems, this numerical criterion also implies a connection between the order of a certain Selmer group and a special value of an L-function. In this talk I will consider the case of a Hecke algebra acting on the cohomology a Shimura curve associated to a quaternion algebra. In this case, one has an analogous map of ring R->T which is known to be an isomorphism, but in many cases the rings R and T fail to be complete intersections. This means that Wiles' numerical criterion will fail to hold. I will describe a method for precisely computing the extent to which the numerical criterion fails (i.e. the 'Wiles defect"), which will turn out to be determined entirely by local information at the primes dividing the discriminant of the quaternion algebra. This is joint work with Gebhard Bockle and Chandrashekhar Khare.