Hi, Camila,
Check another response I gave to a different question, The basics are better explained there.
The formula that relates energy, specific heat, mass, and temperature change is:
q = mCDT
where q is energy, m is a unit denoting some aspect of mass (g, kg, mole, etc.) and DT is the temperature change (T2 - T1)=DT. c is the specific heat of the substance in question. Let the mass be X, the unknown here.
3851.2J = X*(4.184J/gK)*(31.5K)
X = 29.2 grams
Bob