Escape from a Rectangle

Given a point inside an axis-aligned rectangle, compute the minimum distance from the point to the nearest side of the rectangle.

Easy1MathGeometryImplementationInterviewNo attempts yetTime limit2sMemory limit128 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.