According to the principle of calorimetry, if two bodies at different temperatures are mixed together (or kept in contact), heat flows from a body at higher temperature to a body at lower temperature till both the bodies attain the same temperatue. If their is no heat lost to the surroundings, then The heat lost by the hot body = The heat gained by the cold body.