#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const double EPS = 1e-7;
int n;
struct Point {
  int x, y;
} a[MAXN];
int mi, ma;
int Y0;
void Cut(Point a, Point b) {
  if (a.y == b.y) {
    if (b.x > a.x) mi = ma + 100;
    return;
  }
  double x =
      (-(double)b.x * a.y + (double)a.x * b.y - (double)(a.x - b.x) * Y0) /
      (b.y - a.y);
  long long xx;
  if (b.y < a.y) {
    if (x > 0)
      xx = (long long)(x + EPS);
    else
      xx = (long long)(x - 1 + EPS);
    if (xx < ma) ma = xx;
  } else {
    if (x > 0)
      xx = (long long)(x + 1 - EPS);
    else
      xx = (long long)(x - EPS);
    if (xx > mi) mi = xx;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
  if (a[1].x > a[2].x) {
    swap(a[1], a[2]);
    for (int i = 1; i <= n; i++) a[i].y = -a[i].y;
    for (int i = 3; i <= n + 3 - i; i++) swap(a[i], a[n + 3 - i]);
  }
  mi = a[1].x, ma = a[2].x;
  Y0 = a[1].y;
  for (int i = 2; i < n; i++) Cut(a[i], a[i + 1]);
  printf("%d\n", max(0, ma - mi + 1));
  return 0;
}
