UVA Online Judge Problem 612