#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64777216")
const int size = 1001;
struct tpo {
  long long x, y;
} p[size];
long long vect(tpo a, tpo b) { return a.x * b.y - a.y * b.x; }
long long vect(tpo a, tpo b, tpo c) {
  b.x -= a.x;
  b.y -= a.y;
  c.x -= a.x;
  c.y -= a.y;
  return vect(b, c);
}
int n;
void Solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].x >> p[i].y;
  }
  int res = 0;
  double L = min(p[0].x, p[1].x), R = max(p[0].x, p[1].x);
  for (int i = 2; i < n - 1; ++i) {
    int j = i + 1;
    if (p[i].y == p[j].y) {
      bool is1 = (p[i].x < p[j].x);
      bool is2 = p[1].x < p[0].x;
      if (is1 != is2) {
        L = R + 10;
        break;
      }
    } else {
      double t = (double)(p[0].y - p[i].y) / (p[j].y - p[i].y);
      double x = p[i].x + (p[j].x - p[i].x) * t;
      if (p[i].y > p[j].y) {
        R = min(R, x);
      } else
        L = max(L, x);
    }
  }
  if ((int)ceil(L) <= (int)floor(R)) {
    res = (int)floor(R) - (int)ceil(L) + 1;
  }
  cout << res << endl;
}
int main() {
  Solve();
  return 0;
}
