Hide

Problem B
Triangles of a Square

Ashley has given Brandon a square of side $2024$. She also has drawn a single line segment that connects two different sides of the square.

Brandon wants to draw some additional line segments such that it is possible to decompose the square into a set of disjoint triangles, where each triangle has sides that are either subsegments of the sides of the square, or subsegments of any drawn line segment.

Compute the minimum number of additional line segments Brandon needs to draw to make this possible.

Input

Imagine that the square is axis-aligned with its bottom-left corner at $(0, 0)$ and top-right corner at $(2024, 2024)$.

Input has a single line with four integers $x_1, y_1, x_2, y_2$ ($0 \leq x_1, y_1, x_2, y_2 \leq 2024$) specifying the coordinates of the end points of the line segment initially drawn by Ashley. One end point is at $(x_1, y_1)$ and the other end point is at $(x_2, y_2)$.

It is guaranteed the two end points are distinct. Both end points are on sides of the square. If the segment intersects a side of the square, it does so at exactly one point.

Output

Output a single integer, the minimum number of additional line segments Brandon needs to draw.

Sample Input 1 Sample Output 1
0 10 10 0
2
Sample Input 2 Sample Output 2
2024 2024 0 0
0

Please log in to submit a solution to this problem

Log in