ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2206. Runes in the Field 2

Time limit: 4.5 second
Memory limit: 512 MB
Once, Vadim was walking in a field and imagined it as a plane with Cartesian coordinates. There, he saw an infinite number of runes located at points with coordinates (x, y) such that x, y are coprime positive numbers, meaning GCD(x, y) = 1. It goes without saying that their price on the black market is very high, so Vadim decided to use all his strength to collect them.
He had with him a net, which is represented as a convex polygon. Vadim threw it on the ground and then began to collect the runes that fell into it. A rune falls into the net if it is either inside or on the boundary of the thrown net. Vadim doesn’t have time to think, so he asked you to help him count the number of runes in the net.

Input

The first line contains a single integer N — the number of vertices of the polygon describing the thrown net (3 ≤ N ≤ 2 · 105).
In each of the following N lines, two numbers xi, yi are given separated by a space — the coordinates of the vertices of this polygon in counterclockwise order (1 ≤ xi, yi ≤ 2 · 106). The coordinates are given with exactly three decimal places.

Output

Output the number of runes that fell into the net.
Note that despite the real coordinates of the given polygon, you are required to output an exact value.

Sample

inputoutput
3
1.000 1.000
3.000 1.000
1.000 3.000
5
Problem Author: Vadim Barinov
Problem Source: University academic school olympiad in informatics 2022