Contest Duration: - (local time) (300 minutes) Back to Home
A - Bubbler /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 注意

この問題に対する言及は、2021/10/02 18:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。 試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

### 問題文

レストランに来た高橋君は A 円のランチと B 円のドリンクバーを注文しようとしています。

### 制約

• 1 \leq A \leq 1000
• 1 \leq C \lt B \leq 1000
• 1 \leq D \leq 1000
• 入力は全て整数である。

### 入力

A B C D


### 入力例 1

600 200 100 750


### 出力例 1

700


### 入力例 2

600 200 100 650


### 出力例 2

650


### 入力例 3

800 200 100 900


### 出力例 3

900


Score : 9 points

### Warning

Do not make any mention of this problem until October 2, 2021, 6:00 p.m. JST. In case of violation, compensation may be demanded. After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).

### Problem Statement

In a restaurant, Takahashi is about to order an A-yen lunch and a B-yen free refill service. (Yen is the Japanese currency.)
He has a coupon that gives C-yen discount on the free refill service, allowing him to order both for a total of A + B － C yen.
On the other hand, a set menu of the lunch and the free refill service is also available for D yen, but the coupon cannot be applied to this.
Print the minimum total amount of money needed for Takahashi to order both the lunch and the free refill service.

### Constraints

• 1 \leq A \leq 1000
• 1 \leq C \lt B \leq 1000
• 1 \leq D \leq 1000
• All values in input are integers.

### Input

Input is given from Standard Input in the following format:

A B C D


### Output

Print the minimum total amount of money needed for Takahashi to order both the lunch and the free refill service, as an integer.

### Sample Input 1

600 200 100 750


### Sample Output 1

700


They cost 600 + 200 - 100 = 700 yen when he uses the coupon, and 750 yen when he orders the set menu, so he needs to pay 700 yen to order both.

### Sample Input 2

600 200 100 650


### Sample Output 2

650


Again they cost 700 yen when he uses the coupon, but the set menu costs 650 yen this time, so the answer is 650 yen.

### Sample Input 3

800 200 100 900


### Sample Output 3

900