Solved UVa 562