The man swims perpendicular to the flow or velocity of river water.

speed of man = 5 kmph wrt water

boat is going upstream , velocity wrt water = 12 kmph

velocity of water in the river = 2 kmph

The vector component of velocity of water downstream is added to both boatman and the swimmer. When we find the relative velocity of the swimmer wrt boatman, that will be canceled.

relative velocity of swimmer wrt boatman

= velocity of swimmer - velocity of boatman (vector subtraction)

as angle between the two vectors is 90 deg,

magnitude of relative velocity = √(5² + 12²) = 13 kmph

direction: at an angle of tan⁻¹ (12/5) to the flow of water.