Solution for problem 022