#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; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      dx = x[j] - x[i];
      dy = y[j] - y[i];
      if (!dy)
        r = 1e100;
      else
        r = 1. * (y[0] - y[i]) / dy * dx + x[i];
      if (1. * dx * (y[0] - y[i]) - dy * (mr - x[i]) > 0 && r < mr) mr = r;
      if (1. * dx * (y[0] - y[i]) - dy * (nr - x[i]) > 0 && r > nr) nr = r;
    }
  }
  mr = floor(mr) - ceil(nr);
  if (i < n || mr < -1e-12)
    printf("0");
  else
    printf("%.0lf", mr + 1e-12 + 1);
  return 0;
}
