cho.sh
Notes
Loading...

Escape from a Rectangle

Time limit

2s

Memory limit

128 MB

Problem

Hansoo is at the point (x, y) on the coordinate plane. Each side of the rectangle is parallel to a coordinate axis, with lower-left corner (0, 0) and upper-right corner (w, h). Find the minimum distance Hansoo must move to reach the boundary of the rectangle.

Input

The first line contains four integers x, y, w, and h.

Output

Print the minimum distance from the point to the boundary of the rectangle.

Constraints

  • 1 <= w, h <= 1,000
  • 1 <= x <= w - 1
  • 1 <= y <= h - 1
  • x, y, w, and h are integers.