#!/usr/bin/python3 # Formát vstupu: # (počet vrcholů) # (x1) (y1) # ... # (xn) (yn) from math import gcd n = int(input()) grid_points = 0 for i in range(n): x, y = map(int, input().split()) # První souřadnici si zapamatujeme, abychom nakonec mohli přičíst poslední # stranu (xn,yn)...(x1,y1). if i == 0: x1, y1 = x, y x_last, y_last = x, y else: # V Xlast, Ylast si držíme poslední souřadnice. # Připočteme počet mřížových bodů na (x_last,y_last)...(x,y) grid_points += gcd(abs(x_last - x), abs(y_last - y)) x_last, y_last = x, y # Připočti stranu (xn,yn)...(x1,y1). grid_points += gcd(abs(x_last - x1), abs(y_last - y1)) print(grid_points)