#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;
  point() {}
  point(const int x, const int y) : x(x), y(y) {}
} A[100000];
inline bool leftTurn(point A, point B) {
  return (long long)A.x * B.y < (long long)A.y * B.x;
}
inline bool rightTurn(point A, point B) { return !leftTurn(A, B); }
point makeVector(point A, point B) { return point(B.x - A.x, B.y - A.y); }
point opposite(point A) { return point(-A.x, -A.y); }
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &A[i].x, &A[i].y);
  }
  int left = A[0].x;
  int right = A[1].x;
  for (int i = 2; i < n - 1; i++) {
    point segment = makeVector(A[i], A[i + 1]);
    point opp = opposite(segment);
    if (leftTurn(makeVector(A[i], A[0]), segment) &&
        leftTurn(makeVector(A[i], A[1]), segment)) {
      cout << 0 << endl;
      return 0;
    }
    if (!rightTurn(makeVector(A[i], A[0]), segment) ||
        !rightTurn(makeVector(A[i], A[1]), segment)) {
      double t = double(A[0].y - A[i].y) / segment.y;
      if (A[i].y < A[i + 1].y && A[0].x < A[1].x) {
        long long x = ceil(A[i].x + (long long)segment.x * t);
        if (left < x) left = x;
      } else if (A[i].y > A[i + 1].y && A[0].x < A[1].x) {
        long long x = A[i].x + (long long)segment.x * t;
        if (x < right) right = x;
      } else if (A[i].y > A[i + 1].y && A[0].x > A[1].x) {
        long long x = A[i].x + (long long)segment.x * t;
        if (x < left) left = x;
      } else if (A[i].y < A[i + 1].y && A[0].x > A[1].x) {
        long long x = ceil(A[i].x + (long long)segment.x * t);
        if (right < x) right = x;
      }
    }
  }
  if (A[0].x < A[1].x)
    cout << ((right - left + 1 > 0) ? right - left + 1 : 0) << endl;
  else
    cout << ((left - right + 1 > 0) ? left - right + 1 : 0) << endl;
  return 0;
}
