#include <bits/stdc++.h>
using namespace std;
int sign(long long x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
struct point {
  long long x, y;
  point(long long a = 0, long long b = 0) : x(a), y(b) {}
  point operator-(point q) { return point(x - q.x, y - q.y); }
  long long operator%(point q) { return x * q.y - y * q.x; }
};
point T[1001];
long long piso(long long A, long long B) {
  if (B < 0) A = -A, B = -B;
  if (A >= 0)
    return A / B;
  else
    return -((-A + B - 1) / B);
}
long long techo(long long A, long long B) {
  if (B < 0) A = -A, B = -B;
  if (A >= 0)
    return (A + B - 1) / B;
  else
    return A / B;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld %lld", &T[i].x, &T[i].y);
  if (T[2].y > T[0].y) {
    for (int i = 0; i < n; i++) T[i].y = -T[i].y;
    swap(T[0], T[1]);
    reverse(T + 2, T + n);
  }
  T[n] = T[0];
  long long y = T[0].y;
  bool sirve = true;
  long long le = T[0].x, ri = T[1].x;
  for (int i = 2; i < n; i++) {
    long long der = T[1].x;
    long long izq = T[0].x;
    for (int j = 2; j < i; j++)
      if (abs(y - T[j].y) < abs(y - T[i].y)) {
        long long A = T[j].y - T[i].y;
        long long B = T[i].x - T[j].x;
        long long C = T[i].x * A + T[i].y * B;
        der = min(der, piso(C - B * y, A));
      }
    if (i - 1 > 1)
      if (T[i].y == T[i - 1].y && T[i - 2].y > T[i].y &&
          sign((T[i] - T[i - 1]) % (T[i] - T[i - 2])) <= 0)
        sirve = false;
    for (int j = i + 1; j < n; j++)
      if (abs(y - T[j].y) < abs(y - T[i].y)) {
        long long A = T[j].y - T[i].y;
        long long B = T[i].x - T[j].x;
        long long C = T[i].x * A + T[i].y * B;
        izq = max(izq, techo(C - B * y, A));
      }
    if (i + 1 < n)
      if (T[i].y == T[i + 1].y && T[i + 2].y > T[i].y &&
          sign((T[i] - T[i + 1]) % (T[i] - T[i + 2])) >= 0)
        sirve = false;
    if (der < izq)
      sirve = false;
    else if (ri < izq || der < le)
      sirve = false;
    else {
      le = max(izq, le);
      ri = min(der, ri);
    }
  }
  int res = ri - le + 1;
  if (!sirve) res = 0;
  cout << res << endl;
}
