Let N and p be primes such that p divides the numerator of N−1 12 . In this paper, we study the rank gp of the completion of the Hecke algebra acting on cuspidal modular forms of weight 2 and level Γ 0 (N ) at the p-maximal Eisenstein ideal. We give in particular an explicit criterion to know if gp ≥ 3, thus answering partially a question of Mazur.In order to study gp, we develop the theory of higher Eisenstein elements, and compute the first few such elements in four different Hecke modules. This has applications such as generalizations of the Eichler mass formula in characteristic p.