#include <bits/stdc++.h>
using namespace std;
struct rec {
  double x, y;
} ver[1010], p[1010], q[1010], f[10];
int n, m, cnt, now, ans, i;
double a, b, c, eps = 1e-10;
double mul(rec a, rec b, rec c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
void line(rec x, rec y, double &a, double &b, double &c) {
  a = y.y - x.y;
  b = x.x - y.x;
  c = x.y * y.x - x.x * y.y;
}
rec cross(rec x, rec y, double a, double b, double c) {
  double u = fabs(a * x.x + b * x.y + c), v = fabs(a * y.x + b * y.y + c);
  return (rec){(x.x * v + y.x * u) / (u + v), (x.y * v + y.y * u) / (u + v)};
}
void cut(double a, double b, double c) {
  int i, now = 0;
  for (i = 1; i <= cnt; i++)
    if (a * p[i].x + b * p[i].y + c >= 0)
      q[++now] = p[i];
    else {
      if (a * p[i - 1].x + b * p[i - 1].y + c > 0)
        q[++now] = cross(p[i], p[i - 1], a, b, c);
      if (a * p[i + 1].x + b * p[i + 1].y + c > 0)
        q[++now] = cross(p[i], p[i + 1], a, b, c);
    }
  for (i = 1; i <= now; i++) p[i] = q[i];
  cnt = now, p[0] = p[cnt], p[cnt + 1] = p[1];
}
void solve() {
  double a, b, c;
  memcpy(p, ver, sizeof(p));
  p[0] = p[n], cnt = n;
  for (i = 1; i <= n; i++) {
    line(ver[i], ver[i + 1], a, b, c);
    cut(a, b, c);
  }
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> ver[i].x >> ver[i].y;
  ver[n + 1] = ver[1];
  solve();
  for (i = 1; i <= cnt; i++)
    if (fabs(mul(ver[1], ver[2], p[i])) < eps)
      f[++m] = p[i];
    else if (mul(ver[1], ver[2], p[i]) * mul(ver[1], p[i + 1], ver[2]) > eps) {
      line(ver[1], ver[2], a, b, c);
      f[++m] = cross(p[i], p[i + 1], a, b, c);
    }
  if (m == 1) f[2] = f[1];
  if (m) {
    if (f[1].x > f[2].x) swap(f[1], f[2]);
    if (ver[1].x > ver[2].x) swap(ver[1], ver[2]);
    ans = floor(min(ver[2].x, f[2].x)) - ceil(max(ver[1].x, f[1].x)) + 1;
    if (ans < 0) ans = 0;
  }
  cout << ans << endl;
}
