#include <bits/stdc++.h>
using namespace std;
struct point;
struct line;
struct segment;
int n, m;
struct point {
  double x, y;
  bool ok;
  point() : x(0.), y(0.), ok(false) {}
  point(double xx, double yy) : x(xx), y(yy), ok(true) {}
  point(line, line);
  point(line, segment);
} a[1111];
double cross(const point &a, const point &b, const point &c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
struct line {
  double A, B, C;
  line(double Aa = 0., double Bb = 0., double Cc = 0.) : A(Aa), B(Bb), C(Cc) {}
  line(const point &p, const point &q) {
    double a = q.y - p.y, b = p.x - q.x, c = -a * p.x - b * p.y;
    A = a;
    B = b;
    C = c;
  }
  line(segment a);
};
struct segment {
  point p, q;
  segment(point pp = point(), point qq = point()) : p(pp), q(qq) {}
  line median() {
    double mx = (p.x + q.x) * .5, my = (p.y + q.y) * .5;
    line tmp = line(p, q);
    swap(tmp.A, tmp.B);
    tmp.A = -tmp.A;
    tmp.C = -mx * tmp.A - my * tmp.B;
    return tmp;
  }
};
line::line(segment a) { *this = line(a.p, a.q); }
point::point(line a, line b) {
  if (fabs(b.B * a.A - a.B * b.A) < 1E-8) {
    x = y = 0.;
    ok = false;
  } else {
    y = (a.C * b.A - b.C * a.A) / (b.B * a.A - a.B * b.A);
    x = (a.C * b.B - b.C * a.B) / (a.B * b.A - b.B * a.A);
    ok = true;
  }
}
point::point(line a, segment b) {
  point tmp = point(a, line(b));
  if (!tmp.ok || tmp.x > max(b.p.x, b.q.x) || tmp.x < min(b.p.x, b.q.x) ||
      tmp.y > max(b.p.y, b.q.y) || tmp.y < min(b.p.y, b.q.y)) {
    x = y = 0.;
    ok = false;
  } else {
    *this = tmp;
  }
}
double dist2(const point &a, const point &b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
};
double dist(const point &a, const point &b) { return sqrt(dist2(a, b)); };
double u, v;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
  if (a[1].x > a[2].x)
    for (int i = (1); i <= (n); ++i) a[i].x = -a[i].x, a[i].y = -a[i].y;
  line o(a[1], a[2]);
  u = a[1].x;
  v = a[2].x;
  for (int i = (3); i <= (n - 1); ++i) {
    line l(a[i], a[i + 1]);
    point p(o, l);
    if (p.ok) {
      point q(p.x - 1, p.y);
      if (cross(a[i], a[i + 1], q) > 0)
        u = max(u, p.x);
      else
        v = min(v, p.x);
    } else if (cross(a[i], a[i + 1], a[1]) > 0) {
      u = v + 1;
      break;
    }
  }
  int l = ceil(u - 1E-9), r = floor(v + 1E-9);
  printf("%d\n", max(0, r - l + 1));
  return 0;
}
