solution for problem 493