#include <bits/stdc++.h>
using namespace std;
const double E = 1e-8;
const int inf = (int)1e9;
struct pt {
  double x, y;
  pt() {}
  pt(double _x, double _y) : x(_x), y(_y) {}
};
pt v[2000];
double a, b;
double h;
void doit(pt p1, pt p2) {
  if (abs(p1.y - p2.y) < E) {
    if (p1.x < p2.x) {
      a = inf;
      b = -inf;
      return;
    }
  } else if (p1.y < p2.y) {
    double x = p1.x + (p2.x - p1.x) / (p2.y - p1.y) * (h - p1.y);
    a = max(a, x);
  } else {
    double x = p2.x + (p1.x - p2.x) / (p1.y - p2.y) * (h - p2.y);
    b = min(b, x);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf%lf", &v[i].x, &v[i].y);
  v[n] = v[0];
  if (v[0].x > v[1].x) {
    for (int i = 0; i <= n; i++) v[i].x = -v[i].x;
  }
  if (v[0].y < v[2].y) {
    for (int i = 0; i <= n; i++) v[i].y = -v[i].y;
  }
  a = v[0].x;
  b = v[1].x;
  h = v[0].y;
  for (int i = 2; i < n; i++) {
    doit(v[i], v[i + 1]);
  }
  int a0 = (int)floor(a - E) + 1;
  int b0 = (int)floor(b + E);
  if (a0 <= b0)
    printf("%d", b0 - a0 + 1);
  else
    printf("0");
  return 0;
}
