#include <bits/stdc++.h>
struct point {
  int x, y;
  point() { x = y = 0; }
  point(int a, int b) { x = a, y = b; }
  void scan() { scanf("%d%d", &x, &y); }
} p[1005];
point operator-(const point &a, const point &b) {
  return point(a.x - b.x, a.y - b.y);
}
bool operator*(const point &a, const point &b) {
  return a.x * (long long)b.y > b.x * (long long)a.y;
}
int main() {
  int n, i, x, y, l, r;
  for (scanf("%d", &n), i = 0; i < n; i++) p[i].scan();
  l = p[0].x, r = p[1].x, y = p[0].y;
  if (l > r) l ^= r, r ^= l, l ^= r;
  for (p[n] = p[0], i = 1; i < n; i++) {
    for (; l <= r && (p[i + 1] - p[i]) * (point(l - p[i].x, y - p[i].y)); l++)
      ;
    for (; l <= r && (p[i + 1] - p[i]) * (point(r - p[i].x, y - p[i].y)); r--)
      ;
  }
  printf("%d\n", r - l + 1);
  return 0;
}
