#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535;
const double eps = 1e-6;
int n, x[1010], y[1010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", x + i, y + i);
  double l = x[0], r = x[1];
  if (l > r) {
    for (int i = 0; i < n; i++) y[i] = -y[i], x[i] = -x[i];
    l = x[0], r = x[1];
  }
  for (int i = 3; i < n; i++) {
    double ml = x[0], mr = x[1];
    int j = i - 1;
    if (y[i] == y[j]) {
      if (x[j] <= x[i]) r = -1e7;
      continue;
    }
    double dx = x[i] - x[j], dy = y[i] - y[j];
    if (dy < 0) {
      r = min(r, x[i] + -dx * (y[0] - y[i]) / -dy);
    } else
      l = max(l, x[j] + dx * (y[0] - y[j]) / dy);
  }
  long long L = (long long)ceil(l), R = (long long)floor(r);
  if (R >= L)
    printf("%d\n", (int)(R - L + 1));
  else
    puts("0");
}
