Moving Fruit

Compute the fewest single-fruit moves between two baskets so one holds only apples and the other holds only oranges.

Easy1MathNo attempts yetTime limit1sMemory limit32 MB

Problem

There are two baskets, and both hold apples and oranges. The first basket holds AA apples and BB oranges. The second basket holds CC apples and DD oranges.

You may pick up one fruit and move it to the other basket. Repeat that until one basket holds only apples and the other holds only oranges. An empty basket counts as satisfying the condition.

Write a program that computes the minimum number of moves needed.

Input

The first line contains the number of apples AA and the number of oranges BB in the first basket, separated by a space. (0A,B10000 \le A, B \le 1000)

The second line contains the number of apples CC and the number of oranges DD in the second basket, separated by a space. (0C,D10000 \le C, D \le 1000)

Output

Print the minimum number of moves on the first line.