The boundary of the polygon#871

The boundary of the polygon

2 seconds
64 megabytes
Very easy

A polygon in the plane is defined by the integer coordinates of its vertices in the Cartesian coordinate system. It is required to find the number of points with integer coordinates lying on the boundary of the polygon. The sides of the polygon do not touch each other (except for neighboring ones — at vertices) and do not intersect.

Input

The first line contains the number , the following lines - a pair of numbers - the coordinates of points. If you connect the points in this order, and join the first and last point, you obtain the polygon. 3 \leq N \leq 100000, the coordinates of the vertices are integers and do not exceed in absolute value .

Output

Output a single number - the number of points with integer coordinates on the boundary of the polygon.

Examples

Example 1

Loading
Loading