  We study the three-dimensional magnetic structure of solar active region
11158, which produced one X-class and several M-class flares on 2011 February
13$-$16. We focus on the magnetic twist in four flare events, M6.6, X2.2, M1.0,
and M1.1. The magnetic twist is estimated from the nonlinear force-free field
extrapolated from the vector fields obtained from the Helioseismic and Magnetic
Imager on board the Solar Dynamic Observatory using magnetohydrodynamic
relaxation method developed by \cite{2011ApJ...738..161I}. We found that
strongly twisted lines ranging from half-turn to one-turn twist were built up
just before the M6.6- and X2.2 flares and disappeared after that. Because most
of the twist remaining after these flares was less than half-turn twist, this
result suggests that the buildup of magnetic twist over the half-turn twist is
a key process in the production of large flares. On the other hand, even though
these strong twists were also built up just before the M1.0 and M1.1 flares,
most of them remained afterwords. Careful topological analysis before the M1.0
and M1.1 flares shows that the strongly twisted lines were surrounded mostly by
the weakly twisted lines formed in accordance with the clockwise motion of the
positive sunspot, whose footpoints are rooted in strong magnetic flux regions.
These results imply that these weakly twisted lines might suppress the activity
of the strongly twisted lines in the last two M-class flares.
