Solve max stack problem.