#include <bits/stdc++.h>
using namespace std;
int mod(int first) {
  if (first < 0) return -first;
  return first;
}
int area(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  long long aux = (long long)a.first * (b.second - c.second) +
                  (long long)b.first * (c.second - a.second) +
                  (long long)c.first * (a.second - b.second);
  if (aux < 0) return -1;
  return (aux > 0);
}
const int maxn = 1005;
int n, i, normal, sgn, first, second, j, step;
pair<int, int> a[maxn], left2, right2;
int main() {
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
  a[n + 1] = a[1];
  sgn = a[2].first - a[1].first;
  if (sgn < 0)
    sgn = -1;
  else
    sgn = 1;
  left2 = a[1];
  right2 = a[2];
  for (i = 2; i <= n; ++i) {
    first = area(a[i], a[i + 1], left2);
    second = area(a[i], a[i + 1], right2);
    if (first > 0 && second > 0) {
      cout << "0";
      return 0;
    }
    if (first <= 0 && second <= 0) continue;
    if (first <= 0) {
      for (step = 1; step < mod(a[2].first - a[1].first); step <<= 1)
        ;
      for (j = left2.first; step; step >>= 1)
        if (area(a[i], a[i + 1], make_pair(j + step * sgn, left2.second)) <= 0)
          j += step * sgn;
      right2.first = j;
      continue;
    }
    for (step = 1; step < mod(a[2].first - a[1].first); step <<= 1)
      ;
    for (j = right2.first; step; step >>= 1) {
      if (area(a[i], a[i + 1], make_pair(j - step * sgn, left2.second)) <= 0)
        j -= step * sgn;
      left2.first = j;
      continue;
    }
  }
  cout << mod(right2.first - left2.first) + 1;
}
