Problem 145. It is not very fast… needs improvement!