#include <bits/stdc++.h>
int n, x[1001], y[1001], i, j, dx, dy;
double mr, nr, r, t;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
  }
  if (x[0] < x[1]) {
    mr = x[1];
    nr = x[0];
  } else {
    mr = x[0];
    nr = x[1];
  }
  for (i = 2, j = 3; j < n; i = j++) {
    dx = x[j] - x[i];
    dy = y[j] - y[i];
    t = 1. * (y[0] - y[i]) * dx;
    r = dy ? t / dy + x[i] : 1e9;
    if (t - dy * (mr - x[i]) > 0 && r < mr) mr = r;
    if (t - dy * (nr - x[i]) > 0 && r > nr) nr = r;
  }
  mr = floor(mr) - ceil(nr);
  printf("%.0lf", mr < -1e-14 ? 0. : mr + 1.1);
  return 0;
}
