#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const double oo = 1E7, eps = 1E-7;
struct point {
  double x, y;
} P[maxn];
int n;
double ansl, ansr;
point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; }
point operator-(point a, point b) { return (point){a.x - b.x, a.y - b.y}; }
double operator*(point a, point b) { return a.x * b.x + a.y * b.y; }
double operator/(point a, point b) { return a.x * b.y - b.x * a.y; }
double get(point A, point B) {
  double a, b, c, res;
  a = A.y - B.y;
  b = B.x - A.x;
  c = A / B;
  if (a)
    res = (-c - b * P[1].y) / a;
  else
    res = oo;
  return res;
}
int main() {
  int i, j;
  double x, sita;
  scanf("%d", &n);
  scanf("%lf%lf", &P[n].x, &P[n].y);
  for (i = 1; i < n; ++i) scanf("%lf%lf", &P[i].x, &P[i].y);
  ansl = min(P[1].x, P[n].x), ansr = max(P[1].x, P[n].x);
  for (i = 2; i < n; ++i) {
    j = i + 1;
    x = get(P[i], P[j]);
    sita = (P[1].y - P[i].y) * (P[j].x - P[i].x);
    if (sita > (P[j].y - P[i].y) * (ansl - P[i].x)) ansl = max(ansl, x);
    if (sita > (P[j].y - P[i].y) * (ansr - P[i].x)) ansr = min(ansr, x);
  }
  if (ansr >= ansl)
    printf("%.0lf", floor(ansr) - floor(ansl - eps));
  else
    printf("0");
  return 0;
}
