#include <bits/stdc++.h>
using namespace std;
long long cross2(long long x1, long long y1, long long x2, long long y2) {
  return x1 * y2 - x2 * y1;
}
long long cross(long long i, long long j, long long k, const long long* xx,
                const long long* yy) {
  return cross2(xx[j] - xx[i], yy[j] - yy[i], xx[k] - xx[i], yy[k] - yy[i]);
}
int main() {
  int n;
  cin >> n;
  auto* xx = new long long[n];
  auto* yy = new long long[n];
  for (int i = 0; i < n; i++) {
    cin >> xx[i];
    cin >> yy[i];
  }
  bool flip = xx[0] < xx[1];
  long long x = xx[1], y = yy[1];
  for (int i = 0; i < n; i++) {
    xx[i] -= x;
    yy[i] -= y;
    if (flip) {
      xx[i] = -xx[i];
      yy[i] = -yy[i];
    }
  }
  long long left = 0, right = xx[0];
  for (int i = 2; i + 1 < n; i++) {
    long long cright = cross(i, i + 1, 0, xx, yy);
    long long cleft = cross(i, i + 1, 1, xx, yy);
    if (cright > 0 && cleft > 0) {
      cout << 0;
      return 0;
    }
    long long x0 = xx[i], y0 = yy[i], x1 = xx[i + 1], y1 = yy[i + 1];
    if (cright > 0 || cleft > 0) {
      long long p = x0 * (y1 - y0) - y0 * (x1 - x0);
      long long q = y1 - y0;
      if (q < 0) {
        p = -p;
        q = -q;
      }
      if (cright > 0)
        right = min(right, (p / q));
      else
        left = max(left, ((p + q - 1) / q));
    }
  }
  cout << (left <= right ? right - left + 1 : 0) << endl;
}
