So the angle between them is 72°
They both travel for 2 hours, so the 1st went 30 km, and the 2nd went 4 km
This is just a cosine law question ....
x^2 = 30^2 + 4^2 - 2(4)(30)cos72
= 841.83..
x = appr 29.01 km
or, using the fact that the 2nd boat was directly north of the 1st, and noting parallel lines
4/sin45 = x/sin72
xsin45 = 4sin72
x = 4sin72/sin45 = 5.37 km
which is inconsistent with my other answer.
I think you have contradictory information.
Make a sketch and you will see that 2nd boat cannot be directly north of the 1st.
Check your typing or your question itself