There are three heat transfers involved.

#q = "heat to warm ice" + "heat to melt ice" + "heat to warm water"#

#q = q_1 + q_2 +q_3#

The specific heat capacity of ice is #"2090 J·kg"^"-1""°C"^"-1"#

#q_1 = mcΔT = 900 color(red)(cancel(color(black)("kg"))) ×" 2090 J"·color(red)(cancel(color(black)("kg"^"-1""°C"^"-1"))) × 40 color(red)(cancel(color(black)("°C"))) = "75 200 000 J" = "75.2 MJ"#

The heat of fusion of ice is 334 kJ/kg.

#q_2 =mΔ_"fus"H^° = 900 color(red)(cancel(color(black)("kg"))) × "334 kJ"·color(red)(cancel(color(black)("kg"^"-1"))) = "300 600 kJ" = "300.6 MJ"#

The specific heat capacity of water is #"4181 J·kg"^"-1""°C"^"-1"#.

#q_3 = mcΔT = 900 color(red)(cancel(color(black)("kg"))) × "4181 J"·color(red)(cancel(color(black)("kg"^"-1""°C"^"-1"))) × 5 color(red)(cancel(color(black)("°C"))) = "19 000 000 J" = "19 MJ"#.

#q = q_1 + q_2 + q_3 = "(75.2 + 300.6 + 19) MJ" = "395 MJ"#