B, himself, "with respect to B" isstanding still. To change from "traveling at 17 km/h in the direction S 40" E to "0" velocity, you need to subtract the velocity vector. Do the same to A: subtract the vector "17 km/h at S 40 E" from "22 km/h at N 35 E".

You can do that either by setting it up as a triangle and using the cosine and sine laws or by separating the vectors into components. Would you like to try that yourself?