시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 488 414 388 86.607%

문제

세 정수 A, B, C의 평균은 (A+B+C)/3이다. 세 정수의 중앙값은 수의 크기가 증가하는 순서로 정렬했을 때, 가운데 있는 값이다.

두 정수 A와 B가 주어진다. 이때, A, B, C의 평균과 중앙값을 같게 만드는 가장 작은 정수 C를 찾는 프로그램을 작성하시오.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, A와 B가 주어진다. (1 ≤ A ≤ B ≤ 109) 입력의 마지막 줄에는 0이 두 개 주어진다. 

출력

각 테스트 케이스에 대한 정답을 한 줄에 하나씩 출력한다.

예제 입력 1

1 2
6 10
1 1000000000
0 0

예제 출력 1

0
2
-999999998
W3sicHJvYmxlbV9pZCI6IjU2OTEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzYzlcdWFkZTAgXHVjOTExXHVjNTU5XHVhYzEyIFx1YmIzOFx1YzgxYyIsImRlc2NyaXB0aW9uIjoiPHA+XHJcblx0XHVjMTM4IFx1YzgxNVx1YzIxOCBBLCBCLCBDXHVjNzU4IFx1ZDNjOVx1YWRlMFx1Yzc0MCAoQStCK0MpXC8zXHVjNzc0XHViMmU0LiBcdWMxMzggXHVjODE1XHVjMjE4XHVjNzU4IFx1YzkxMVx1YzU1OVx1YWMxMlx1Yzc0MCBcdWMyMThcdWM3NTggXHVkMDZjXHVhZTMwXHVhYzAwIFx1Yzk5ZFx1YWMwMFx1ZDU1OFx1YjI5NCBcdWMyMWNcdWMxMWNcdWI4NWMgXHVjODE1XHViODJjXHVkNTg4XHVjNzQ0IFx1YjU0YywgXHVhYzAwXHVjNmI0XHViMzcwIFx1Yzc4OFx1YjI5NCBcdWFjMTJcdWM3NzRcdWIyZTQuPFwvcD5cclxuXHJcbjxwPlxyXG5cdFx1YjQ1MCBcdWM4MTVcdWMyMTggQVx1YzY0MCBCXHVhYzAwIFx1YzhmY1x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