  Let $N$ and $p$ be primes such that $p$ divides the numerator of
$\frac{N-1}{12}$. In this paper, we study the rank $g_p$ of the completion of
the Hecke algebra acting on cuspidal modular forms of weight $2$ and level
$\Gamma_0(N)$ at the $p$-maximal Eisenstein ideal. We give in particular an
explicit criterion to know if $g_p \geq 3$, thus answering partially a question
of Mazur.
  In order to study $g_p$, we develop the theory of \textit{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$.
