The solution is written below. If you want to think about it a little more, you can go back to the problem or the hints.