solve 5, but the code take 20 minutes to get answer
solve 5