#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
struct point {
  double x, y;
  point() {}
  point(double _x, double _y) {
    x = _x;
    y = _y;
  }
  point operator+(const point &t) { return point(x + t.x, y + t.y); }
  point operator-(const point &t) { return point(x - t.x, y - t.y); }
  double dist(const point &t) {
    return ((x - t.x) * (x - t.x) + (y - t.y) * (y - t.y));
  }
};
struct line {
  double a, b, c;
  line() {}
  line(double _a, double _b, double _c) {
    a = _a;
    b = _b;
    c = _c;
  }
  void build(const point &p, const point &q) {
    a = p.y - q.y;
    b = q.x - p.x;
    c = -(p.x * (p.y - q.y) + p.y * (q.x - p.x));
  }
};
int n, lt, rt;
point p[2000];
double mx = 1e+15, mn = -(1e+15);
bool intersect(const line &a, point &res) {
  if (fabs(a.a) <= eps) return false;
  res.y = p[0].y;
  res.x = (-a.c - (a.b * res.y)) / a.a;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
  p[n] = p[0];
  lt = int(min(p[0].x, p[1].x));
  rt = int(max(p[0].x, p[1].x));
  p[n + 1] = p[1];
  for (int i = 1; i < n; i++) {
    line l;
    l.build(p[i], p[i + 1]);
    point res, tt = p[i + 1] - p[i];
    if (intersect(l, res)) {
      if (tt.y < eps)
        mx = min(mx, res.x);
      else
        mn = max(mn, res.x);
    } else if ((p[1].x - p[0].x) * tt.x > eps) {
      printf("0\n");
      return 0;
    }
  }
  int x = ceil(mn - eps), y = floor(mx + eps);
  printf("%d\n", max(0, min(y, rt) - max(x, lt) + 1));
  return 0;
}
