Category

Similar Problems

0730. The Segment

Time limit : 1000 ms
Memory limit : 64 mb

The ends of the segment have integer coordinates. Find the number of points on segment with integer coordinates.














Input

Four numbers - the coordinates x1y1x2y2 of the segment ends. All input numbers are not greater than 109 by the absolute value. The ends do not coincide.

Output

The required number of points.

Samples

Input

Output

1

0 0 3 3

4

2

1 1 2 3

2

 

Tayyorladi: Azat Yusupov
Text from: e-olimp.com