acm International Collegiate Programming Contest

Links

A B C D E F G H

Problem C

Training Schedule for ICPC

With little time remaining until ICPC, you decided to reschedule your training plan. As maintaining both mental and physical vitality is important, you decided to spend n days of the remaining n + m days for training, and m days for repose. The question is which days should be used for the training and which for the repose. A schedule that increases your ICPC power more is better.

Training days increase the power, and consecutive training days are more effective. One day of training on the k-th day of consecutive training days increases the power by 2k − 1, where k = 1 for the first day of the consecutive training days. A single training day increases the power by only 1, but two consecutive training days increase it by 1 + 3 = 4, and three consecutive training days increase it by 1 + 3 + 5 = 9.

Repose days, on the other hand, decrease the power, and consecutive repose days decrease it more rapidly. One day of repose on the k-th day of consecutive repose days decreases the power by 2k − 1, where k = 1 for the first day of the consecutive repose days. A single repose day decreases the power by only 1, but two consecutive repose days decrease it by 1 + 3 = 4, and three consecutive repose days decrease it by 1 + 3 + 5 = 9.

Let us compute the largest increment of your ICPC power after n + m days of training and repose by the best training schedule. Note that, if you have too many repose days, this may be negative.

Input

The input consists of multiple datasets, each in the following format.

n m

Here, n and m are the numbers of training and repose days, respectively. Neither of them exceeds 106, and at least one of them is non-zero.

The end of the input is indicated by a line containing two zeros. The number of datasets does not exceed 100.

Output

For each of the datasets, output in a line the largest increment of ICPC power after n + m days of training and repose by the best training schedule.

Sample Input

1 1
3 2
6 1
1 6
0 3
2 4
7 9
0 0

Output for the Sample Input

0
7
35
-17
-9
-4
10
(End of Problem C) A B C D E F G H