#include <bits/stdc++.h>
using namespace std;
long long x[1005], y[1005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld%lld", x + i, y + i);
  if (y[n - 1] > y[0]) {
    for (int i = 0; i < n; i++) {
      x[i] = -x[i];
      y[i] = -y[i];
    }
  }
  int idx = n - 1, l, r, i;
  for (i = x[0]; i <= x[1] && idx > 1; i++) {
    while ((x[idx] - i) * (y[idx - 1] - y[0]) >=
               (x[idx - 1] - i) * (y[idx] - y[0]) &&
           idx > 1)
      idx--;
  }
  l = i - 1;
  idx = 1;
  for (i = x[1]; i >= x[0] && idx < n - 1; i--) {
    while ((x[idx] - i) * (y[idx + 1] - y[0]) <=
               (x[idx + 1] - i) * (y[idx] - y[0]) &&
           idx < n - 1)
      idx++;
  }
  r = i + 1;
  printf("%d\n", max(r - l + 1, 0));
  return 0;
}
