Since the directions are fairly simple in this question, you could just draw this out on a plane and notice that the shape made will be a triangle, and hence you can find the distance traveled by finding the length of the hypotenuse, which is (c):
a^2 + b^2 = c^2
and so pluggin in the distance of 4 and 3 km, we get that c=5km.
so the answer is
4. 5 km