solution for problem 348