Fill the 5 and pour it into the 3, which leaves 2 in the 5. Empty the 3 and pour the 2 into it. Fill the 5 again and top up the 3, which takes 1 litre. That leaves exactly 4 in the 5-litre jug.