#P59. [KBC005C] Segment

[KBC005C] Segment

Source

This problem is adapted from Long Long OJ. All rights reserved.

Problem Description

Given two endpoints (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) of a line segment on a plane, find the number of points on this line segment (excluding the endpoints) where both the xx-coordinate and yy-coordinate are integers.

Input Format

This problem contains multiple test cases.

For each test case, input a line with four integers x1,y1,x2,y2x_1,y_1,x_2,y_2 separated by spaces.

The input ends with EOF.

Output Format

For each test case, output a line containing the answer.

Samples

1 11 5 3
114 514 114 514
3
0

Data Range

For 100%100\% of the data: 109x1,x2,y1,y2109-10^9\le x_1,x_2,y_1,y_2\le 10^9, and the number of input test cases does not exceed 2525.