Solves problem 5