This is a related rates problem. You'll want to use Pythagorean Theorem as the model and differentiate implicitly with respect to time.
x^2 + y^2 = z^2
2x*dx/dt + 2y*dy/dt = 2z*dz/dt
where dx/dt = 21 and dy/dt = 17
You'll also need to use the fact that 6 hours has passed in order to calculate the distance that Ship A has traveled (then add that to the 30 miles that was given). This represents 'x'. Also calculate the distance that Ship B has traveled, which represents 'y'. These are the two legs of the right triangle that is formed. Using these distances, you can use the Pythagorean Theorem to solve for the distance between the two ships at 6pm, which is 'z'. Substituting these amounts will allow you to solve for dz/dt, which is how fast the distance between the ships is changing.