Solution 8: solve a part of P5