#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  point() {}
  point(int x, int y) : x(x), y(y) {}
} p[1010];
point operator-(const point &a, const point &b) {
  return point(a.x - b.x, a.y - b.y);
}
long long operator*(const point &a, const point &b) {
  return (long long)a.x * b.y - (long long)a.y * b.x;
}
int main() {
  int n, i, x, y, low, high;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    p[i] = point(x, y);
  }
  low = p[0].x;
  high = p[1].x;
  if (low > high) swap(low, high);
  p[n] = p[0];
  for (i = 0; i < n; i++) {
    while (low <= high && (p[i + 1] - p[i]) * (point(low, p[0].y) - p[i]) > 0)
      low++;
    while (low <= high && (p[i + 1] - p[i]) * (point(high, p[0].y) - p[i]) > 0)
      high--;
  }
  cout << high - low + 1 << endl;
}
