Solved UVa 12504