UVa problem: Earn for Future - Trivial once you find the trick