#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int MAXN = 1000;
int n;
struct Point {
  int x, y;
} p[MAXN + 10];
void getABC(Point x, Point y, double& a, double& b, double& c) {
  a = y.y - x.y;
  b = x.x - y.x;
  c = y.x * (double)x.y - x.x * (double)y.y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
  }
  bool rev = p[3].y > p[1].y;
  p[n + 1] = p[1];
  double lb = -1e9, rb = 1e9;
  for (int i = 2; i <= n; i++) {
    if (p[i].y != p[i + 1].y) {
      double a, b, c;
      getABC(p[i], p[i + 1], a, b, c);
      double interPos = (b * p[1].y + c) / -a;
      if (p[i + 1].y > p[i].y) {
        lb = max(lb, interPos);
      } else {
        rb = min(rb, interPos);
      }
    } else if (!rev && p[i].x < p[i + 1].x || rev && p[i].x > p[i + 1].x) {
      puts("0");
      return 0;
    }
  }
  int ilb = ceil(lb - EPS), irb = floor(rb + EPS);
  printf("%d\n", max(0, irb - ilb + 1));
  return 0;
}
