#include <bits/stdc++.h>
using namespace std;
int x[1010], y[1010];
int main(void) {
  int N, i, j;
  cin >> N;
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> x[i] >> y[i];
  if (x[0] > x[1])
    for ((i) = 0; (i) < (int)(N); (i)++) x[i] = -x[i];
  int tmp = y[0];
  for ((i) = 0; (i) < (int)(N); (i)++) y[i] -= tmp;
  if (y[2] < 0)
    for ((i) = 0; (i) < (int)(N); (i)++) y[i] = -y[i];
  double low = x[0] - 1.0, high = x[1] + 1.0;
  for (i = 1; i < N; i++) {
    j = (i + 1) % N;
    if (y[i] == y[j]) {
      if (x[i] < x[j]) low = x[1] + 1.0;
      continue;
    }
    double p = x[i] - (double)(x[j] - x[i]) / (y[j] - y[i]) * y[i];
    if (y[i] < y[j])
      high = min(high, p);
    else
      low = max(low, p);
  }
  int ans = 0;
  for (i = x[0]; i <= x[1]; i++)
    if (i > low - 1.0E-7 && i < high + 1.0E-7) ans++;
  cout << ans << endl;
  return 0;
}
