#include <bits/stdc++.h>
using namespace std;
int n;
pair<double, double> p[1011];
double calc(pair<double, double> a, pair<double, double> b, double y) {
  return a.first + (a.first - b.first) * (y - a.second) / (a.second - b.second);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf%lf", &p[i].first, &p[i].second);
  if (p[1].first > p[2].first) {
    swap(p[1], p[2]);
    reverse(p + 3, p + n + 1);
    for (int i = 3; i <= n; ++i)
      p[i].second = p[1].second + p[1].second - p[i].second;
  }
  double L(p[1].first), R(p[2].first);
  for (int i = 3; i < n; ++i)
    if (p[i + 1].second > p[i].second)
      L = max(calc(p[i], p[i + 1], p[1].second), L);
    else if (p[i + 1].second < p[i].second)
      R = min(calc(p[i], p[i + 1], p[1].second), R);
    else if (p[i + 1].first > p[i].first) {
      puts("0");
      return 0;
    }
  L += -1e-11 + 1, R += 1e-11 + 1;
  printf("%d\n", max(int(R) - int(L), 0));
  return 0;
}
