#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const double eps = 1e-6;
int x[maxn], y[maxn], n;
int main() {
  scanf("%d", &n);
  for (int a = 1; a <= n; a++)
    scanf("%d%d", &x[a], &y[a]), x[a] += 20, y[a] += 20;
  x[n + 1] = x[1];
  y[n + 1] = y[1];
  int l = min(x[1], x[2]), r = max(x[1], x[2]);
  for (int a = 1; a <= n; a++) {
    long long A = y[a + 1] - y[a];
    long long B = x[a] - x[a + 1];
    long long C = -A * x[a] - B * y[a];
    if (A == 0) {
      if (B * y[1] + C < 0) {
        printf("0\n");
        return 0;
      }
    } else {
      if (A > 0) {
        int nowx = (int)((double)(-B * y[1] - C) / A + 1 - eps);
        l = max(l, nowx);
      } else {
        int nowx = (int)((double)(-B * y[1] - C) / A + eps);
        r = min(r, nowx);
      }
    }
  }
  if (l > r)
    printf("0\n");
  else
    printf("%d\n", r - l + 1);
  return 0;
}
