Solved UVa 580