#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
struct Fraction {
  long long p, q;
  Fraction(long long p) : p(p), q(1) {}
  Fraction(long long p, long long q) : p(p), q(q) { relax(); }
  void relax() {
    assert(q != 0);
    if (q < 0) {
      p = -p;
      q = -q;
    }
    long long g = gcd(abs(p), abs(q));
    p /= g;
    q /= g;
  }
  bool operator<(const Fraction &t) const { return p * t.q < q * t.p; }
};
struct Point {
  long long x, y;
  Point operator-(const Point &t) const { return {x - t.x, y - t.y}; }
};
inline long long cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
inline long long ccw(Point a, Point b, Point c) { return cross(b - a, c - a); }
bool inAngle(Point p, Point a, Point b, Point o) {
  assert(ccw(a, b, o) != 0);
  if (ccw(a, b, o) < 0) swap(a, b);
  return ccw(a, p, o) >= 0 && ccw(b, p, o) <= 0;
}
Fraction findRatio(Point p, Point a, Point b, Point o) {
  a = a - o;
  b = b - o;
  p = p - o;
  return Fraction(cross(a, p), cross(a, p) - cross(b, p));
}
const int MAXN = 1050;
Point a[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld%lld", &a[i].x, &a[i].y);
  Fraction l(0, 1), r(1, 1);
  for (int k = 2; k < n; k++) {
    for (int i = 2; i < k; i++) {
      if (inAngle(a[i], a[0], a[1], a[k]))
        r = min(r, findRatio(a[i], a[0], a[1], a[k]));
      else if (ccw(a[k], a[1], a[i]) > 0) {
        printf("0\n");
        return 0;
      }
    }
    for (int i = k + 1; i < n; i++) {
      if (inAngle(a[i], a[0], a[1], a[k]))
        l = max(l, findRatio(a[i], a[0], a[1], a[k]));
      else if (ccw(a[k], a[0], a[i]) < 0) {
        printf("0\n");
        return 0;
      }
    }
  }
  long long g = gcd(abs(a[0].x - a[1].x), abs(a[0].y - a[1].y));
  long long lbnd = (l.p * g - 1) / l.q + 1, rbnd = r.p * g / r.q;
  if (lbnd <= rbnd)
    printf("%lld\n", rbnd - lbnd + 1);
  else
    printf("0\n");
}
