Problem 36(Brute force; NOT OPTIMIZED)