#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
struct Tpoint {
  int x, y;
  Tpoint() {}
  Tpoint(int _x, int _y) {
    x = _x;
    y = _y;
  }
} H[maxn];
int n, ret;
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &H[i].x, &H[i].y);
}
long long Cross(Tpoint p0, Tpoint p1, Tpoint p2) {
  return ((long long)p1.x - p0.x) * (p2.y - p0.y) -
         ((long long)p2.x - p0.x) * (p1.y - p0.y);
}
void work() {
  int l = H[1].x, r = H[2].x;
  if (l > r) {
    int t = l;
    l = r;
    r = t;
  }
  H[n + 1] = H[1];
  for (int i = 2; i <= n && l <= r; i++) {
    while (l <= r && Cross(H[i], H[i + 1], Tpoint(l, H[1].y)) > 0) l++;
    while (l <= r && Cross(H[i], H[i + 1], Tpoint(r, H[1].y)) > 0) r--;
  }
  ret = r - l + 1;
}
void print() { printf("%d\n", ret); }
int main() {
  init();
  work();
  print();
  return 0;
}
