#include <bits/stdc++.h>
using namespace std;
int n;
struct Point {
  int x, y;
  inline void Read() { cin >> x >> y; }
} P[1003], A, B;
inline long long Cross(const Point& O, const Point& A, const Point& B) {
  long long x1 = A.x - O.x, x2 = B.x - O.x, y1 = A.y - O.y, y2 = B.y - O.y;
  return x1 * y2 - x2 * y1;
}
int Calc() {
  Point Left = A, Right = B;
  for (int i = 2; i <= n; i++)
    if (Cross(Left, P[i - 1], P[i]) > 0) {
      if (P[i].y == P[i - 1].y) return 0;
      double t = 1.0 * (Left.y - P[i].y) / (P[i].y - P[i - 1].y) *
                 (P[i].x - P[i - 1].x),
             pos = t + P[i].x;
      if (pos + 1e-5 < Left.x)
        return 0;
      else
        Left.x = (int)ceil(pos);
    }
  if (Left.x > B.x) return 0;
  for (int i = 2; i <= n; i++)
    if (Cross(Left, P[i - 1], P[i]) > 0) return 0;
  for (int i = n - 1; i; i--)
    if (Cross(Right, P[i + 1], P[i]) < 0) {
      if (P[i].y == P[i + 1].y) return 0;
      double t = 1.0 * (Right.y - P[i].y) / (P[i].y - P[i + 1].y) *
                 (P[i].x - P[i + 1].x),
             pos = t + P[i].x;
      if (pos - 1e-5 > Right.x)
        return 0;
      else
        Right.x = (int)floor(pos);
    }
  if (Right.x < A.x) return 0;
  for (int i = n - 1; i; i--)
    if (Cross(Right, P[i + 1], P[i]) < 0) return 0;
  return Right.x - Left.x + 1;
}
int main() {
  cin >> n;
  A.Read(), B.Read();
  n -= 2;
  for (int i = 1; i <= n; i++) P[i].Read();
  if (A.x > B.x) {
    swap(A, B);
    for (int i = 1; i <= n; i++) P[i].y = 2 * A.y - P[i].y;
    for (int i = 1, j = n; i < j; i++, j--) swap(P[i], P[j]);
  }
  cout << Calc() << endl;
  getchar();
  getchar();
  return 0;
}
