Great feast
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
After the end of the world programming semifinal, the organizers decided to gather all participants for a great feast and purchased \(x\) liters of orange juice and \(y\) liters of pomegranate juice.
The only thing the organizers did not account for was the participants’ preferences. It turned out that among all the participants, there are \(a\) people who like exclusively orange juice, \(b\) who like exclusively pomegranate juice, and \(c\) who like both juices.
One liter of juice is intended for exactly one competition participant, and if there is not enough juice for them or it is not their favorite juice, they will remain upset.
Considering this, the organizers ask you to help them calculate how many upset participants there will be at the feast if they distribute the juice optimally (i.e., in a way that minimizes the number of upset people at the feast).
Note that some excess juice may remain after the distribution. Also, there might not be enough juice for all participants.
Input
The first line contains three integers \(a\), \(b\), \(c\).
The second line contains two integers \(x\), \(y\).
Output
In a single line, print an integer — the minimum number of upset competition participants.
Constraints
\(1 \le a, b, c, x, y \le 10^8\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 1 1 1 2 1 | 0 |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 4 7 7 7 | 4 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|