Solved UVa 821