You really enjoy the Olympics. To help keep track of how each country is performing, you've decided to implement your own scoring system where bronze medals are worth point, silver medals are worth points, and gold medals are worth points. To win the Olympics, a country needs a score larger than any other country. You've been keeping track of how the other countries are performing. Currently, the top-scoring country that isn't Canada has a score of points. Canada currently has bronze medals, silver medals, and gold medals. You would like to know, what is the minimum number of additional medals of any kind needed for Canada to win?
Constraints
For this problem, you will be required to pass all samples to receive any points.
Input Specification
You will read four space-separated integers , , , and .
Output Specification
Output the minimum number of medals of any kind Canada needs to win according to the scoring system you've designed.
Sample Input
7 2 1 0
Sample Output
1
Explanation
The score of Canada is . Canada can win with either one gold for a final score of or one silver medal for a final score of . It can be proven that this is the minimum number of additional medals Canada needs to win.
Comments