eolymp
bolt
Try our new interface for solving problems
Problems

Mean Median Problem

Mean Median Problem

The mean of three integers a, b and c is (a + b + c) / 3. The median of three integers is the one that would be in the middle if they are sorted in non-decreasing order.

Given two integers a and b, return the minimum possible integer c such that the mean and the median of a, b and c are equal.

Input

Each test case is given in a single line that contains two integers a and b (1ab109). The last test case is followed by a line containing two zeros.

Output

For each test case output one line containing the minimum possible integer c such that the mean and the median of a, b and c are equal.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 2
6 10
1 1000000000
0 0
Output example #1
0
2
-999999998
Source 2010 ACM South America, Latin America, Warmup Session, October 22, Problem A