Solves the UVa Online Judge problem 120, stack of pancakes.