If there's no energy lost from the system then,
energy lost by hot substance cooling down = energy gained by cold substance heating up.
mc(T(hot) - T(equilibrium) ) = mc (T(equilibrium) - T(cold))
m = mass
c = specific heat capacity
T = temperature
since c are the same