A - Difference Max 解説 /

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

配点 : 100

問題文

整数 a, b, c, d が与えられます。
a ≤ x ≤ b,\ c ≤ y ≤ d となるように整数 x, y を選ぶとき、 x - y の最大値を求めてください。

制約

  • 入力は全て整数
  • -100 ≤ a ≤ b ≤ 100
  • -100 ≤ c ≤ d ≤ 100

入力

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

a b
c d

出力

答えを出力せよ。


入力例 1

0 10
0 10

出力例 1

10

(x, y) = (10, 0) のとき最大値 x - y = 10 をとります。


入力例 2

-100 -100
100 100

出力例 2

-200

入力例 3

-100 100
-100 100

出力例 3

200

Score : 100 points

Problem Statement

Given are integers a, b, c, and d.
We will choose integers x and y such that a ≤ x ≤ b and c ≤ y ≤ d. Find the maximum possible value of x - y here.

Constraints

  • All values in input are integers.
  • -100 ≤ a ≤ b ≤ 100
  • -100 ≤ c ≤ d ≤ 100

Input

Input is given from Standard Input in the following format:

a b
c d

Output

Print the answer.


Sample Input 1

0 10
0 10

Sample Output 1

10

(x, y) = (10, 0) achieves the maximum value x - y = 10.


Sample Input 2

-100 -100
100 100

Sample Output 2

-200

Sample Input 3

-100 100
-100 100

Sample Output 3

200