A - Traveling Budget 解説 /

実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 100

問題文

あなたは、電車とバスを乗り継いで旅行をする計画を立てました。 電車は旅程に沿って通常のきっぷを買うと A 円かかり、乗り放題きっぷを買うと B 円かかります。 バスは旅程に沿って通常のきっぷを買うと C 円かかり、乗り放題きっぷを買うと D 円かかります。

電車およびバスについて通常の切符を買うか乗り放題きっぷを買うかをうまく選んだときの、運賃の合計の最小値を求めてください。

制約

  • 1 \leq A \leq 1,000
  • 1 \leq B \leq 1,000
  • 1 \leq C \leq 1,000
  • 1 \leq D \leq 1,000
  • 入力値はすべて整数である。

入力

入力は以下の形式で標準入力から与えられる。

A
B
C
D

出力

運賃の合計の最小値を出力せよ。


入力例 1

600
300
220
420

出力例 1

520

電車の通常のきっぷを買うと 600 円かかり、乗り放題きっぷを買うと 300 円かかります。 よって、電車については乗り放題きっぷを 300 円で買うほうが運賃が少なくなります。 一方、バスについては通常の切符を 220 円で買うほうが運賃が少なくなります。

したがって、運賃の合計の最小値は 300 + 220 = 520 円となります。


入力例 2

555
555
400
200

出力例 2

755

入力例 3

549
817
715
603

出力例 3

1152

Score : 100 points

Problem Statement

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.


Sample Input 1

600
300
220
420

Sample Output 1

520

The train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket. Thus, the optimal choice for trains is to buy an unlimited ticket for 300 yen. On the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.

Therefore, the minimum total fare is 300 + 220 = 520 yen.


Sample Input 2

555
555
400
200

Sample Output 2

755

Sample Input 3

549
817
715
603

Sample Output 3

1152