#include <bits/stdc++.h>
using namespace std;
struct T {
  int x, y;
  void read() { scanf("%d%d", &x, &y); }
  T(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  T operator-(T b) { return T(x - b.x, y - b.y); }
  long long operator*(T b) { return (long long)x * b.y - (long long)y * b.x; }
} a[10000];
int n;
int main() {
  cin >> n;
  for (int i = (1); i <= (n); i++) a[i].read();
  if (a[1].x > a[2].x) {
    swap(a[1], a[2]), reverse(a + 3, a + n + 1);
    for (int i = (1); i <= (n); i++) a[i].y = -a[i].y;
  }
  a[n + 1] = a[1];
  int l = a[1].x, r = a[2].x;
  for (int i = (3); i <= (n); i++) {
    while (l <= r && (T(l, a[1].y) - a[i]) * (a[i + 1] - a[i]) < 0) l++;
    while (l <= r && (T(r, a[1].y) - a[i]) * (a[i - 1] - a[i]) > 0) r--;
  }
  cout << r - l + 1 << endl;
  return 0;
}
