#include <bits/stdc++.h>
class P {
 public:
  P(long long int _x, long long int _y) : x(_x), y(_y) {}
  long long int x;
  long long int y;
  bool operator<(P const &rhs) const {
    if (x == rhs.x) return y < rhs.y;
    return x < rhs.x;
  }
  double getSlope() const { return double(y / x); };
  bool operator==(P const &rhs) const { return x == rhs.x && y == rhs.y; }
};
P operator-(P const &lhs, P const &rhs) {
  return P(lhs.x - rhs.x, lhs.y - rhs.y);
}
long long int cross3(P const &a, P const &b, P const &c) {
  P one = b - a;
  P two = c - b;
  return one.x * two.y - two.x * one.y;
}
long long int getIntPoints(long long int const a, long long int const b) {
  return std::abs(a - b) + 1;
}
double getIntersection(P const &seg, P const &base, P const &a) {
  double yShift = base.y - a.y;
  double xShift = yShift / seg.y * seg.x;
  return a.x + xShift;
}
long long int solve(std::vector<P> const &points) {
  if (points.size() == 3) {
    return getIntPoints(points[0].x, points[1].x);
  }
  P a = points[0], b = points[1];
  P min = points[0], max = points[1];
  if (max < min) {
    std::swap(min, max);
  }
  for (int i = 2; i < points.size(); i++) {
    P seg = points[i] - points[i - 1];
    auto c = cross3(min, points[i - 1], points[i]);
    if (c > 0) {
      if (seg.y == 0) {
        min.x = max.x + 1;
      } else if (seg.x == 0) {
        min.x = std::max(points[i].x, min.x);
      } else {
        min.x = std::max(double(min.x),
                         std::ceil(getIntersection(seg, points[0], points[i])));
      }
    }
    c = cross3(max, points[i - 1], points[i]);
    if (c > 0) {
      if (seg.y == 0) {
        max.x = min.x - 1;
      } else if (seg.x == 0) {
        max.x = std::min(points[i].x, max.x);
      } else {
        max.x = std::min(std::floor(getIntersection(seg, points[0], points[i])),
                         double(max.x));
      }
    }
    if (min.x > max.x) return 0;
  }
  return getIntPoints(min.x, max.x);
}
int main() {
  int c;
  long long int x, y;
  std::vector<P> points;
  std::cin >> c;
  points.reserve(c);
  while (c > 0) {
    std::cin >> x >> y;
    points.emplace_back(x, y);
    c--;
  }
  std::cout << solve(points);
}
