#include <bits/stdc++.h>
using namespace std;
const int c = 1024;
const int cmax = 1000001;
const double eps = 1e-8;
struct point {
  int x, y;
};
int lr, rr;
point a[c];
int n;
inline int sign(const long long &a) {
  if (a > 0)
    return 1;
  else if (a < 0)
    return -1;
  else
    return 0;
}
inline int sign(const double &a) {
  if (a > 0)
    return 1;
  else if (a < 0)
    return -1;
  else
    return 0;
}
inline int rndl(double a) {
  int s = sign(a);
  int r1 = int(floor(fabs(a) + eps));
  int r2 = int(ceil(fabs(a) - eps));
  if (s > 0)
    return r1;
  else
    return -r2;
}
inline int rndr(double a) {
  int s = sign(a);
  int r1 = int(floor(fabs(a) + eps));
  int r2 = int(ceil(fabs(a) - eps));
  if (s > 0)
    return r2;
  else
    return -r1;
}
inline double sqr(double a) { return a * a; }
inline double dist(point a, point b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
inline double an(point a, point b, point c, point d) {
  return (double(b.x - a.x) * (d.x - c.x) + double(b.y - a.y) * (d.y - c.y)) /
         (dist(a, b) * dist(c, d));
}
int main() {
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; ++i) scanf("%d%d", &a[i].x, &a[i].y);
  lr = min(a[1].x, a[2].x);
  rr = max(a[1].x, a[2].x);
  int lf, rg, md;
  for (i = 3; i < n; ++i) {
    double ca = an(a[1], a[2], a[i], a[i % n + 1]);
    if (ca == 1) {
      rr = lr - 1;
      break;
    }
    if (ca == -1) continue;
    double px =
        -(double(a[i % n + 1].x - a[i].x) * a[1].y +
          double(a[i].x) * a[i % n + 1].y - double(a[i].y) * a[i % n + 1].x) /
        (a[i].y - a[i % n + 1].y);
    if (!(abs(a[i].y - a[1].y) > abs(a[i % n + 1].y - a[1].y) ^
          a[1].x > a[2].x))
      rr = min(rr, rndl(px));
    else
      lr = max(lr, rndr(px));
  }
  printf("%d\n", max(rr - lr + 1, 0));
  return 0;
}
