I tried this but check my maths anyway....
Here you have various processes:
First steam cools down to
We can change into grams
I used the absolute value to avoid confusion; it is heat that goes out of the system and is considered conventionally negative (heat in=positive, heat out=negative) but I didn't want to confuse you so remember that it is heat released into the environment.
You should get 5320 kJ.
Here is a schematic cooling curve for water.
You are starting with the vapour at the top of the red graph, cooling it to 100 °C, condensing the steam along the horizontal line, and then cooling the water to the bottom of the red curve.
Thus, there are three separate heat removals involved in this problem:
#q_1#= heat removed by cooling the steam from 174 °C to 100 °C #q_2#= heat removed by condensing the steam to water at 100 °C #q_3#= heat removed by cooling the water from 100 °C to 40 °C
The process releases 5320 kJ of heat energy.