eolymp
bolt
Try our new interface for solving problems
Problems

The Segment

The Segment

\includegraphics{https://static.e-olymp.com/content/4b/4bde6fe5e3c76d5cbc101c3dc47c3c1d8815682b.gif} The endpoints of the segment have integer coordinates. Count the number of points on the segment with integer coordinates. \InputFile Four integers represent the coordinates $x_1, y_1, x_2, y_2$ of the endpoints of the segment. The coordinate values do not exceed $2 \cdot 10^9$ in absolute value. \OutputFile Print the number of points on the segment with integer coordinates.
Time limit 1 second
Memory limit 128 MiB
Input example #1
0 0 3 3
Output example #1
4
Input example #2
2 1 6 3
Output example #2
3