#include <bits/stdc++.h>
using namespace std;
struct Point {
  double X, Y;
};
const double eps = 1e-8;
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = c - 48;
  while (c = getchar(), c >= '0' && c <= '9') X = X * 10 + c - 48;
  return X;
}
int Floor(double X) {
  int T = (int)X;
  if (X - T > 1 - eps) T++;
  return T;
}
int Ceil(double X) {
  int T = (int)X;
  if (X - T > eps) T++;
  return T;
}
int main() {
  int N = Get();
  static Point P[1000];
  for (int i = 0; i < N; i++) {
    P[i].X = Get();
    P[i].Y = Get();
  }
  if (P[2].Y < P[0].Y)
    for (int i = 0; i < N; i++) P[i].Y = -P[i].Y;
  double H = P[0].Y, Left = P[0].X, Right = P[1].X;
  bool Flag = (Left > Right);
  if (Flag) swap(Left, Right);
  for (int i = 2; i + 1 < N; i++) {
    Point A = P[i], B = P[i + 1];
    if (A.Y == B.Y && ((A.X < B.X) ^ Flag)) {
      Left = Right + 1;
    }
    if (A.Y == B.Y) continue;
    double X = ((A.X - B.X) * H - A.X * B.Y + B.X * A.Y) / (A.Y - B.Y);
    if ((A.Y > B.Y) ^ Flag)
      Left = max(Left, X);
    else
      Right = min(Right, X);
  }
  printf("%d\n", (Left > Right) ? 0 : Floor(Right) - Ceil(Left) + 1);
  return 0;
}
