You planned a trip using trains and buses. The train fare will be A yen (the currency of…
- User
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.
Find the minimum total fare when the optimal choices are made for trains and buses.
Constraints
- 1 \leq A \leq 1 000
- 1 \leq B \leq 1 000
- 1 \leq C \leq 1 000
- 1 \leq D \leq 1 000
- All input values are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the minimum total fare.
Examples
Input
600 300 220 420
Output
520
Input
555 555 400 200
Output
755
Input
549 817 715 603
Output
1152
Assistant
python# Read input values A = int(input()) B = int(input()) C = int(input()) D = int(input()) # Calculate minimum fare for each transportation and sum them min_train = min(A, B) min_bus = min(C, D) total = min_train + min_bus # Output the result print(total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.