#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
};
point s[1111];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> s[i].x >> s[i].y;
  long long mn = min(s[0].x, s[1].x);
  long long mx = max(s[0].x, s[1].x);
  for (long long i = 2; i < n; i++) {
    if (s[i].y == s[i - 1].y) {
      if ((s[i].x > s[i - 1].x && s[0].y > s[2].y) ||
          (s[i].x < s[i - 1].x && s[0].y < s[2].y)) {
        cout << 0 << endl;
        return 0;
      } else
        continue;
    }
    double y1 = s[i].y;
    double y2 = s[i - 1].y;
    double x1 = s[i].x;
    double x2 = s[i - 1].x;
    double A = y1 - y2;
    double B = x2 - x1;
    double C = y2 * x1 - y1 * x2;
    double cross = (-B * s[0].y - C) / A;
    long long x = (long long)cross;
    if (s[i].y < s[i - 1].y) {
      mx = min(mx, (long long)(cross + 1000000 + 1e-9) - 1000000);
    } else {
      mn = max(mn, (long long)(ceil(cross - 2e-9) + 1e-9));
    }
  }
  if (mn > mx) {
    cout << 0 << endl;
  } else
    cout << mx - mn + 1 << endl;
  return 0;
}
