题目描述
Problem Description
Takahashi is at a restaurant and plans to order a lunch for $A$ yen and a drink bar for $B$ yen.
Takahashi has a drink bar discount coupon worth $C$ yen, and using the coupon, he can order both for a total of $A + B - C$ yen.
Alternatively, he can order a set menu for lunch and drink bar for $D$ yen, but he cannot apply the discount coupon to this set menu.
Output the minimum amount Takahashi needs to pay to order both the lunch and the drink bar.
Input Format
The input is given from the standard input in the following format:
$A$ $B$ $C$ $D$
Output Format
Output the minimum amount Takahashi needs to pay to order both the lunch and the drink bar.
Sample Input and Output
Sample Input #1
600 200 100 750
Sample Output #1
700
Sample Input #2
600 200 100 650
Sample Output #2
650
Sample Input #3
800 200 100 900
Sample Output #3
900
Notes/Hints
Constraints
- $1 \leq A \leq 1000$
- $1 \leq C < B \leq 1000$
- $1 \leq D \leq 1000$
- All inputs are integers.
Sample Explanation 1
The amount using the discount coupon is $600 + 200 - 100 = 700$ yen, and the amount for the set menu is $750$ yen. Therefore, Takahashi can order both the lunch and the drink bar for $700$ yen.
Sample Explanation 2
The amount using the discount coupon is the same as in Sample Input 1, which is $700$ yen. However, the amount for the set menu is $650$ yen, so the answer is $650$ yen.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分