#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
};
bool multi(point p1, point p2, point p3) {
  return (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x) > 0;
}
bool mul(point p1, point p2) {
  if (p1.x * p2.y - p1.y * p2.x >= 0) return 1;
  return 0;
}
point p[1005];
int n;
bool mark[1005];
int ABS(int i) {
  if (i < 0) i = -i;
  return i;
}
point cal(point p1, point p2) {
  double y = p[0].y;
  double x = p1.x + (y - p1.y) * (p1.x - p2.x) / (p1.y - p2.y);
  point p3;
  p3.x = x;
  p3.y = y;
  return p3;
}
point p1, p2;
point p3, p4;
int main() {
  int i, j, k;
  double minx, maxx;
  int s;
  while (cin >> n) {
    for (i = 0; i < n; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
    p[n] = p[0];
    maxx = minx = p[0].x;
    if (maxx < p[1].x)
      maxx = p[1].x;
    else
      minx = p[1].x;
    p3.x = p[1].x - p[0].x;
    p3.y = 0;
    if (p[0].x < p[1].x)
      for (i = 1; i < n; i++) {
        if (p[i].y == p[i + 1].y) {
          if ((p[i + 1].x - p[i].x) * p3.x > 0) break;
          continue;
        }
        p1 = cal(p[i], p[i + 1]);
        p4.x = p[i + 1].x - p[i].x;
        p4.y = p[i + 1].y - p[i].y;
        p2 = p1;
        if (mul(p4, p3)) {
          if (minx <= p1.x && p1.x <= maxx)
            maxx = p1.x;
          else if (p1.x < minx)
            break;
        } else {
          if (minx <= p1.x && p1.x <= maxx)
            minx = p1.x;
          else if (p1.x > maxx)
            break;
        }
      }
    else {
      for (i = 1; i < n; i++) {
        if (p[i].y == p[i + 1].y) {
          if ((p[i + 1].x - p[i].x) * p3.x > 0) break;
          continue;
        }
        p1 = cal(p[i], p[i + 1]);
        p4.x = p[i + 1].x - p[i].x;
        p4.y = p[i + 1].y - p[i].y;
        p2 = p1;
        if (!mul(p4, p3)) {
          if (minx <= p1.x && p1.x <= maxx)
            maxx = p1.x;
          else if (p1.x < minx)
            break;
        } else {
          if (minx <= p1.x && p1.x <= maxx)
            minx = p1.x;
          else if (p1.x > maxx)
            break;
        }
      }
    }
    if (i < n)
      cout << "0" << endl;
    else {
      s = int(maxx) - int(minx) + 1;
      if (minx != double(int(minx))) s -= 1;
      cout << s << endl;
    }
  }
  return 0;
}
