#RELAYE. 方眼紙と線分

方眼紙と線分

Score : 100100 points

Problem Statement

Takahashi is drawing a segment on grid paper.

From a certain square, a square that is xx squares to the right and yy squares above, is denoted as square (x,y)(x, y).

When Takahashi draws a segment connecting the lower left corner of square (A,B)(A, B) and the lower left corner of square (C,D)(C, D), find the number of the squares crossed by the segment.

Here, the segment is said to cross a square if the segment has non-empty intersection with the region within the square, excluding the boundary.

Constraints

  • 1A,B,C,D1091 \leq A, B, C, D \leq 10^9
  • At least one of ACA \neq C and BDB \neq D holds.

Input

The input is given from Standard Input in the following format:

AA BB CC DD

Output

Print the number of the squares crossed by the segment.

1 1 3 4
4
2 3 10 7
8